Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?]: Streaming/ async generator doesn't work #1477

Closed
2 tasks done
ducan-ne opened this issue May 14, 2024 · 6 comments
Closed
2 tasks done

[Bug?]: Streaming/ async generator doesn't work #1477

ducan-ne opened this issue May 14, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@ducan-ne
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 馃槸

It shows a error when I consume data from a server function

Expected behavior 馃

Should work as it was implemented in seroval

Steps to reproduce 馃暪

Steps:

I've made the reproduction here
https://github.com/ducan-ne/solid-async-generator-reproduction/blob/main/src/actions.tsx
https://github.com/ducan-ne/solid-async-generator-reproduction/blob/main/src/components/Counter.tsx

Context 馃敠

In case it's needed: node 20, macos

Your environment 馃寧

node 20, macos
@ducan-ne ducan-ne added the bug Something isn't working label May 14, 2024
@ducan-ne
Copy link
Author

It's not bug from sevoral, I've confirmed it here lxsmnsyc/seroval#31

@lxsmnsyc
Copy link
Member

lxsmnsyc commented May 15, 2024

I've re-tested this over again, seems like a seroval thing specifically the runtime for the async iterator, but let's just keep the tracking issue here for better visibility.

@ryansolid
Copy link
Member

I've re-tested this over again, seems like a seroval thing specifically the runtime for the async iterator, but let's just keep the tracking issue here for better visibility.

Not quite following. Is it on the seroval side?

@lxsmnsyc
Copy link
Member

lxsmnsyc commented May 16, 2024

@ryansolid Yep, it was a one character mistake on the minified stream constructor. It is fixed now in 1.0.7.

This didn't really impact anything as the issue only happens when there's an immediate, single-push on the stream (stream thinks that the the value is the only thing in the buffer and ends immediately). For any other kind of delayed pushes, or immediate set of push-and-close, the stream normally works.

async function* foo() {
  "use server";
  // Adding another yield here or a sleep doesn't break.
  yield "This breaks";
  await sleep(1000);
  yield "delayed";
}

const example = await foo();
for await (const x of example) {
  console.log(x);
}

@ducan-ne
Copy link
Author

Confirmed, the issue is now fixed.
CleanShot 2024-05-16 at 15 33 22@2x

export const getABC = async function* () {
  "use server"
  yield { abc: true }

  await new Promise((resolve) => setTimeout(resolve, 5000))
  yield { xyz: true }
}

@ryansolid
Copy link
Member

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants