Skip to content

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

Open
@renekaesler

Description

@renekaesler

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    streamIssues and PRs related to the stream subsystem.web streams

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions