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

Streams: fix closed getters #12750

Merged
merged 2 commits into from
Feb 6, 2022
Merged

Streams: fix closed getters #12750

merged 2 commits into from
Feb 6, 2022

Conversation

MattiasBuelens
Copy link
Contributor

Summary

The documentation for the closed getters of ReadableStreamBYOBReader, ReadableStreamDefaultReader and WritableStreamDefaultWriter claim that they resolve when the reader/writer's lock is released. In reality, they reject when the lock is released.

Motivation

The current documentation is incorrect, and may give developers the wrong expectation when using these getters.

Supporting details

The official specification for ReadableStreamDefaultReader says:

await reader.closed

Returns a promise that will be fulfilled when the stream becomes closed, or rejected if the stream ever errors or the reader’s lock is released before the stream finishes closing.

A similar wording can be found in the specification of ReadableStreamBYOBReader and WritableStreamDefaultWriter.

Related issues

This was initially discovered in nodejs/node#41858 (comment), as Node's docs contain the same mistake.

The specification itself also had this mistake, but this was fixed in 2018: whatwg/streams#914. It's possible that the MDN docs were written using the (incorrect) specification from before that change.

Metadata

  • Adds a new document
  • Rewrites (or significantly expands) a document
  • Fixes a typo, bug, or other error

@MattiasBuelens MattiasBuelens requested a review from a team as a code owner February 5, 2022 16:35
@MattiasBuelens MattiasBuelens requested review from Elchi3 and removed request for a team February 5, 2022 16:35
@github-actions github-actions bot added the Content:WebAPI Web API docs label Feb 5, 2022
@sideshowbarker sideshowbarker merged commit bac781d into mdn:main Feb 6, 2022
@sideshowbarker
Copy link
Collaborator

Howdy Mattias — great to see you here. Thanks much for catching this and fixing it, and congrats on landing your first docs change here — welcome aboard 🎉

@MattiasBuelens MattiasBuelens deleted the streams-fix-closed branch February 6, 2022 10:11
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Content:WebAPI Web API docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants