diff --git a/index.bs b/index.bs index ba3fe8660..7a44b4ebe 100644 --- a/index.bs +++ b/index.bs @@ -1870,7 +1870,9 @@ has the following [=struct/items=]: exception. 1. If [=this=].[=ReadableByteStreamController/[[stream]]=].[=ReadableStream/[[state]]=] is not "`readable`", throw a {{TypeError}} exception. - 1. Perform ? [$ReadableByteStreamControllerClose$]([=this=]). + 1. Perform ! [$ReadableByteStreamControllerClose$]([=this=]). + 1. If [=this=].[=ReadableByteStreamController/[[stream]]=].[=ReadableStream/[[state]]=] is + "`errored`", throw [=this=].[=ReadableByteStreamController/[[stream]]=].[=ReadableStream/[[storedError]]=].
@@ -2573,7 +2575,9 @@ create them does not matter. [$ReadableByteStreamControllerClose$](|otherBranch|.[=ReadableStream/[[controller]]=]). 1. If |chunk| is not undefined, 1. Assert: |chunk|.\[[ByteLength]] is 0. - 1. If |byobCanceled| is false, perform ! + 1. If |byobCanceled| is false and + |byobBranch|.[=ReadableStream/[[controller]]=].[=ReadableByteStreamController/[[pendingPullIntos]]=] + is not [=list/is empty|empty=], perform ! [$ReadableByteStreamControllerRespondWithNewView$](|byobBranch|.[=ReadableStream/[[controller]]=], |chunk|). 1. If |otherCanceled| is false and @@ -3249,7 +3253,7 @@ The following abstract operations support the implementation of the by |firstPendingPullInto|'s [=pull-into descriptor/element size=] is not 0, 1. Let |e| be a new {{TypeError}} exception. 1. Perform ! [$ReadableByteStreamControllerError$](|controller|, |e|). - 1. Throw |e|. + 1. Return. 1. Perform ! [$ReadableByteStreamControllerClearAlgorithms$](|controller|). 1. Perform ! [$ReadableStreamClose$](|stream|).
diff --git a/reference-implementation/lib/ReadableByteStreamController-impl.js b/reference-implementation/lib/ReadableByteStreamController-impl.js index eac1a028a..3b0fdd7b0 100644 --- a/reference-implementation/lib/ReadableByteStreamController-impl.js +++ b/reference-implementation/lib/ReadableByteStreamController-impl.js @@ -25,6 +25,10 @@ exports.implementation = class ReadableByteStreamControllerImpl { } aos.ReadableByteStreamControllerClose(this); + + if (this._stream._state === 'errored') { + throw this._stream._storedError; + } } enqueue(chunk) { diff --git a/reference-implementation/lib/abstract-ops/readable-streams.js b/reference-implementation/lib/abstract-ops/readable-streams.js index 3127768cd..31e0e3a97 100644 --- a/reference-implementation/lib/abstract-ops/readable-streams.js +++ b/reference-implementation/lib/abstract-ops/readable-streams.js @@ -631,7 +631,7 @@ function ReadableByteStreamTee(stream) { if (chunk !== undefined) { assert(chunk.byteLength === 0); - if (byobCanceled === false) { + if (byobCanceled === false && byobBranch._controller._pendingPullIntos.length > 0) { ReadableByteStreamControllerRespondWithNewView(byobBranch._controller, chunk); } if (otherCanceled === false && otherBranch._controller._pendingPullIntos.length > 0) { @@ -1276,7 +1276,7 @@ function ReadableByteStreamControllerClose(controller) { const e = new TypeError('Insufficient bytes to fill elements in the given buffer'); ReadableByteStreamControllerError(controller, e); - throw e; + return; } }