File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
reference-implementation/lib Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -559,6 +559,7 @@ Instances of <code>ReadableStreamController</code> are created with the internal
559559
560560<pre is="emu-alg">
561561 1. If IsReadableStreamController(*this*) is *false*, throw a *TypeError* exception.
562+ 1. If *this*@[[controlledReadableStream]] @[[state]] is not "readable", throw a *TypeError* exception.
562563 1. Return ErrorReadableStream(*this*@[[controlledReadableStream]] ).
563564</pre>
564565
@@ -841,8 +842,9 @@ Instances of <code>ReadableStreamReader</code> are created with the internal slo
841842
842843<h4 id="error-readable-stream" aoid="ErrorReadableStream">ErrorReadableStream ( stream, e )</h4>
843844
845+
844846<pre is="emu-alg">
845- 1. If _stream_@[[state]] is not "readable", throw a *TypeError* exception .
847+ 1. Assert: _stream_@[[state]] is "readable".
846848 1. Let _stream_@[[queue]] be a new empty List.
847849 1. Set _stream_@[[storedError]] to _e_.
848850 1. Set _stream_@[[state]] to "errored".
Original file line number Diff line number Diff line change @@ -198,6 +198,10 @@ class ReadableStreamController {
198198 throw new TypeError ( 'ReadableStreamController.prototype.error can only be used on a ReadableStreamController' ) ;
199199 }
200200
201+ if ( this . _controlledReadableStream . _state !== 'readable' ) {
202+ throw new TypeError ( `The stream is ${ this . _controlledReadableStream . _state } and so cannot be errored` ) ;
203+ }
204+
201205 return ErrorReadableStream ( this . _controlledReadableStream , e ) ;
202206 }
203207}
@@ -425,9 +429,7 @@ function EnqueueInReadableStream(stream, chunk) {
425429}
426430
427431function ErrorReadableStream ( stream , e ) {
428- if ( stream . _state !== 'readable' ) {
429- throw new TypeError ( `The stream is ${ stream . _state } and so cannot be errored` ) ;
430- }
432+ assert ( stream . _state === 'readable' ) ;
431433
432434 stream . _queue = [ ] ;
433435 stream . _storedError = e ;
You can’t perform that action at this time.
0 commit comments