Skip to content

Commit 05be429

Browse files
committed
Ensure transferList is empty for non owning readable streams
1 parent cb9c2a1 commit 05be429

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

index.bs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,6 +1585,8 @@ the following table:
15851585
for="ReadableStreamDefaultController">enqueue(|chunk|, |options|)</dfn> method steps are:
15861586

15871587
1. Let |transferList| be |options|["transfer"].
1588+
1. If |transferList| is not [=list/is empty|empty=] and [=this=].[=ReadableStreamDefaultController/[[isOwning]]=] is false
1589+
throw a {{TypeError}} exception.
15881590
1. If ! [$ReadableStreamDefaultControllerCanCloseOrEnqueue$]([=this=]) is false, throw a
15891591
{{TypeError}} exception.
15901592
1. Perform ? [$ReadableStreamDefaultControllerEnqueue$]([=this=], |chunk|, |transferList|).

reference-implementation/lib/ReadableStreamDefaultController-impl.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ exports.implementation = class ReadableStreamDefaultControllerImpl {
1919

2020
enqueue(chunk, options) {
2121
const transferList = options ? options.transfer : undefined;
22+
if (transferList.length && !this._isOwning) {
23+
throw new TypeError('The stream is not an owning stream and cannot make use of options');
24+
}
2225
if (aos.ReadableStreamDefaultControllerCanCloseOrEnqueue(this) === false) {
2326
throw new TypeError('The stream is not in a state that permits enqueue');
2427
}

0 commit comments

Comments
 (0)