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

TransformStream writable and writer exit prematurely #450

Open
guest271314 opened this issue Jan 19, 2024 · 5 comments
Open

TransformStream writable and writer exit prematurely #450

guest271314 opened this issue Jan 19, 2024 · 5 comments

Comments

@guest271314
Copy link
Contributor

Consider this code

transformstream-response-test.js

(async () => {
  try {
    let { readable, writable } = new TransformStream();
    let writer = writable.getWriter();
    new Response(readable).text().then(console.log);
    let encoder = new TextEncoder();
    console.log(readable, writable, writer);
    for (const data of "abcdef") {
      console.log({ data }); // {"data": "a"}
      await writer.ready;
      await writer.write(encoder.encode(data));
    }
    await writer.close();
    await writer.closed;
    console.log(
      "We never get here... if we comment line 4 and uncomment line 15",
    );
    // console.log(await new Response(readable).text());
  } catch (e) {
    console.error(e);
  }
})();

tjs, which still just logs

{ data: 'a' } 
[object ReadableStream]

Expected result: "abcdef"

See MattiasBuelens/web-streams-polyfill#143.

@saghul
Copy link
Owner

saghul commented Jan 19, 2024

Thanks for reporting it upstream. I'm using that polyfill, so once it gets a fix I can bump the dependency here.

@saghul
Copy link
Owner

saghul commented Mar 7, 2024

Looks like a limitation of the fetch polyfill we use , right @guest271314 ? Can I close this then?

@guest271314
Copy link
Contributor Author

Looks like a limitation of the fetch polyfill we use , right @guest271314 ?

Looks like it.

Can I close this then?

Let's fix it. Implement WHATWG Streams, including Transferable Streams, and full-duplex streaming.

@saghul
Copy link
Owner

saghul commented Mar 8, 2024

That might be a bit of a tall order, but we might get there. As usual, patches are more than welcome!

@guest271314
Copy link
Contributor Author

@saghul deno and node implement full-duplex streaming and processing upload streaming. I know what the implementation should look like. Might nt be today or tomorrow when we get this working. We should strive for excellence, no matter how long it takes to get there.

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

No branches or pull requests

2 participants