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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming a response #211

Closed
cyco130 opened this issue Oct 25, 2022 · 3 comments
Closed

Streaming a response #211

cyco130 opened this issue Oct 25, 2022 · 3 comments
Labels

Comments

@cyco130
Copy link
Contributor

cyco130 commented Oct 25, 2022

Describe the bug
Returning a Response created from a ReadableStream doesn't seem to work.

To Reproduce

  1. Run the following file with lagon dev stream.js:
export function handler(request) {
  return new Response(
    new ReadableStream({
      pull(controller) {
        controller.enqueue(new Uint8Array([65, 66, 67]));
        controller.close();
      },
    }),
  );
}
  1. Open http://127.0.0.1:1234 in a browser.
  2. Notice it hangs.

I also tried creating a ReadableStream via TransformStream.

Expected behavior
It should display ABC.

Information:

  • OS: Linux Mint on amd64
  • Browser: Tried with a few (Chrome, Firefox, curl)
  • Version: lagon-cli 0.1.0
@cyco130 cyco130 added the bug label Oct 25, 2022
@QuiiBz
Copy link
Member

QuiiBz commented Oct 25, 2022

I think this has been fixed in #204, let me try. I haven't yet merged the release for this (#203).

@QuiiBz
Copy link
Member

QuiiBz commented Oct 25, 2022

Can confirm that the issue was fixed by #204! I'll do a release soon, so you'll have to npm i -g @lagon/cli again to upgrade.

Screenshot 2022-10-25 at 09 14 41

@QuiiBz
Copy link
Member

QuiiBz commented Oct 25, 2022

Just released version 0.3.3, which also includes some more fixes and improvements. Tested again with your code and it's working fine!

-> npm i -g @lagon/cli@latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants