Skip to content

Iterating cancelled ReadableStream #39715

Description

@ronag

This is kind of weird behavior I'm not sure what to think about. Iterating a cancelled readable stream will not throw...

const { ReadableStream } = require('stream/web')

const stream = new ReadableStream({
  async start (controller) {
  },
  async pull () {
  },
  async cancel (reason) {
  }
})

async function main () {
  for await (const chunk of stream) {
  }
  assert(false) // ouch
}

stream.cancel(new Error())

main().catch(err => {
  console.log(err)
})

This means that e.g. helpers from #39594 can succeeded without any data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    web streamsIssues and PRs related to the Web Streams API.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions