Skip to content

stream: fix isDetachedBuffer validations in ReadableStream#44114

Merged
nodejs-github-bot merged 9 commits intonodejs:mainfrom
daeyeon:main.use-same-validator-220728.Thu.7686
Aug 18, 2022
Merged

stream: fix isDetachedBuffer validations in ReadableStream#44114
nodejs-github-bot merged 9 commits intonodejs:mainfrom
daeyeon:main.use-same-validator-220728.Thu.7686

Conversation

@daeyeon
Copy link
Member

@daeyeon daeyeon commented Aug 3, 2022

This fixes validations below related to isDetachedBuffer using a function introduced in #43866.

https://streams.spec.whatwg.org/#rs-byob-request-respond

The respond(bytesWritten) method steps are:

If this.[[controller]] is undefined, throw a TypeError exception.
If ! IsDetachedBuffer(this.[[view]].[[ArrayBuffer]]) is true, throw a TypeError exception.

https://streams.spec.whatwg.org/#byob-reader-read

The read(view) method steps are:

If view.[[ByteLength]] is 0, return a promise rejected with a TypeError exception.
If view.[[ViewedArrayBuffer]].[[ArrayBufferByteLength]] is 0, return a promise rejected with a TypeError exception.
If ! IsDetachedBuffer(view.[[ViewedArrayBuffer]]) is true, return a promise rejected with a TypeError exception.

https://streams.spec.whatwg.org/#readable-byte-stream-controller-enqueue

  1. If controller.[[pendingPullIntos]] is not empty,

8.1 Let firstPendingPullInto be controller.[[pendingPullIntos]][0].
8.2 If ! IsDetachedBuffer(firstPendingPullInto’s buffer) is true, throw a TypeError exception.

Refs: #43866 (review)

Signed-off-by: Daeyeon Jeong daeyeon.dev@gmail.com

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. web streams

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants