Skip to content

Commit 839a5a6

Browse files
Editorial: assert that async iterator's reader is always active
Fixes #1246.
1 parent 0fac034 commit 839a5a6

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

index.bs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,8 +1012,7 @@ default-reader-asynciterator-prototype-internal-slots">Asynchronous iteration</h
10121012
ignore>stream</var> and |iterator|, are:
10131013

10141014
1. Let |reader| be |iterator|'s [=ReadableStream async iterator/reader=].
1015-
1. If |reader|.[=ReadableStreamGenericReader/[[stream]]=] is undefined, return [=a promise rejected
1016-
with=] a {{TypeError}}.
1015+
1. Assert: |reader|.[=ReadableStreamGenericReader/[[stream]]=] is not undefined.
10171016
1. Let |promise| be [=a new promise=].
10181017
1. Let |readRequest| be a new [=read request=] with the following [=struct/items=]:
10191018
: [=read request/chunk steps=], given |chunk|
@@ -1036,8 +1035,7 @@ default-reader-asynciterator-prototype-internal-slots">Asynchronous iteration</h
10361035
ignore>stream</var>, |iterator|, and |arg|, are:
10371036

10381037
1. Let |reader| be |iterator|'s [=ReadableStream async iterator/reader=].
1039-
1. If |reader|.[=ReadableStreamGenericReader/[[stream]]=] is undefined, return [=a promise resolved
1040-
with=] undefined.
1038+
1. Assert: |reader|.[=ReadableStreamGenericReader/[[stream]]=] is not undefined.
10411039
1. Assert: |reader|.[=ReadableStreamDefaultReader/[[readRequests]]=] is [=list/is empty|empty=],
10421040
as the async iterator machinery guarantees that any previous calls to `next()` have settled
10431041
before this is called.

reference-implementation/lib/ReadableStream-impl.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,7 @@ exports.implementation = class ReadableStreamImpl {
119119

120120
[idlUtils.asyncIteratorNext](iterator) {
121121
const reader = iterator._reader;
122-
if (reader._stream === undefined) {
123-
return promiseRejectedWith(
124-
new TypeError('Cannot get the next iteration result once the reader has been released')
125-
);
126-
}
122+
assert(reader._stream !== undefined);
127123

128124
const promise = newPromise();
129125
const readRequest = {
@@ -143,10 +139,7 @@ exports.implementation = class ReadableStreamImpl {
143139

144140
[idlUtils.asyncIteratorReturn](iterator, arg) {
145141
const reader = iterator._reader;
146-
if (reader._stream === undefined) {
147-
return promiseResolvedWith(undefined);
148-
}
149-
142+
assert(reader._stream !== undefined);
150143
assert(reader._readRequests.length === 0);
151144

152145
if (iterator._preventCancel === false) {

0 commit comments

Comments
 (0)