node icon indicating copy to clipboard operation
node copied to clipboard

stream: fix `isDetachedBuffer` validations in `ReadableStream`

Open daeyeon opened this issue 1 year ago • 2 comments

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

  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: https://github.com/nodejs/node/pull/43866#pullrequestreview-1047386968

Signed-off-by: Daeyeon Jeong [email protected]

daeyeon avatar Aug 03 '22 12:08 daeyeon

CI: https://ci.nodejs.org/job/node-test-pull-request/45915/

nodejs-github-bot avatar Aug 08 '22 08:08 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/45921/

nodejs-github-bot avatar Aug 08 '22 13:08 nodejs-github-bot

@aduh95 Applied the suggestions, PTAL.

daeyeon avatar Aug 18 '22 00:08 daeyeon

CI: https://ci.nodejs.org/job/node-test-pull-request/46057/

nodejs-github-bot avatar Aug 18 '22 02:08 nodejs-github-bot

Landed in 937520a7648e43a06f10dee116baad5ed4112977

nodejs-github-bot avatar Aug 18 '22 08:08 nodejs-github-bot

Depends on https://github.com/nodejs/node/pull/43866

juanarbol avatar Sep 30 '22 03:09 juanarbol