node
node copied to clipboard
stream: fix `isDetachedBuffer` validations in `ReadableStream`
This fixes validations below related to isDetachedBuffer
using a function introduced in https://github.com/nodejs/node/pull/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
- 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: https://github.com/nodejs/node/pull/43866#pullrequestreview-1047386968
Signed-off-by: Daeyeon Jeong [email protected]
CI: https://ci.nodejs.org/job/node-test-pull-request/45915/
CI: https://ci.nodejs.org/job/node-test-pull-request/45921/
@aduh95 Applied the suggestions, PTAL.
CI: https://ci.nodejs.org/job/node-test-pull-request/46057/
Landed in 937520a7648e43a06f10dee116baad5ed4112977
Depends on https://github.com/nodejs/node/pull/43866