Skip to content

ReadableStream.values().return() should return undefined, instead of cancellation reason #57681

Open
@compulim

Description

@compulim

Version

22.14.0

Platform

Microsoft Windows NT 10.0.26100.0 x64

Subsystem

No response

What steps will reproduce the bug?

(async () => {
  const stream = new ReadableStream();

  const values = stream.values({ preventCancel: true });

  const returnResult = await values.return('Cancellation reason');

  // EXPECT: { done: true, value: undefined }
  // ACTUAL: { done: true, value: 'Cancellation reason' }
  console.log(returnResult);
})()

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

It always reproduce.

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

According to WHATWG Streams - Asynchronous iteration. When the iterator return, it should return undefined if preventCancel is set (see point 6.)

The reason (denoted by arg in the spec) is only used for ReadableStreamReaderGenericCancel(reader, arg).

Image

What do you see instead?

The reason is being returned as IteratorResult.

Image

Additional information

This also repro in Chrome 134.0.6998.89, Edge 134.0.3124.93, and Firefox 136.0.4.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions