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

Readable.fromWeb doesn't end on empty string #56474

Open
renekaesler opened this issue Jan 5, 2025 · 0 comments
Open

Readable.fromWeb doesn't end on empty string #56474

renekaesler opened this issue Jan 5, 2025 · 0 comments

Comments

@renekaesler
Copy link

Version

v23.5.0

Platform

Linux xiaomi-mi-pro-gtx 6.8.0-51-generic #52-Ubuntu SMP PREEMPT_DYNAMIC Thu Dec  5 13:09:44 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

import { Readable } from "node:stream";

const response = new Response({
  async *[Symbol.asyncIterator]() {
    yield '' // works only with non-empty string
  }
})

const stream = Readable.fromWeb(response.body);
// const stream = Readable.from('') // works as expected

stream.on('data', chunk => {
  console.log(`data: ${chunk}`)
})

stream.on('end', () => {
  console.log('ended')
});

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

Similar to the Readable.from stream, the Readable.fromWeb stream should trigger both 'data' & 'end' events.

What do you see instead?

data & end events are only triggered, when the response string is not empty.

Additional information

No response

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

1 participant