stream: ended streams should resolve the async iteration
Fixes: https://github.com/nodejs/node/issues/23891 PR-URL: https://github.com/nodejs/node/pull/23901 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
124d91667a
commit
398418dd26
@ -127,7 +127,10 @@ const createReadableStreamAsyncIterator = (stream) => {
|
|||||||
[kLastResolve]: { value: null, writable: true },
|
[kLastResolve]: { value: null, writable: true },
|
||||||
[kLastReject]: { value: null, writable: true },
|
[kLastReject]: { value: null, writable: true },
|
||||||
[kError]: { value: null, writable: true },
|
[kError]: { value: null, writable: true },
|
||||||
[kEnded]: { value: false, writable: true },
|
[kEnded]: {
|
||||||
|
value: stream._readableState.endEmitted,
|
||||||
|
writable: true
|
||||||
|
},
|
||||||
[kLastPromise]: { value: null, writable: true },
|
[kLastPromise]: { value: null, writable: true },
|
||||||
// the function passed to new Promise
|
// the function passed to new Promise
|
||||||
// is cached so we avoid allocating a new
|
// is cached so we avoid allocating a new
|
||||||
|
@ -362,6 +362,24 @@ async function tests() {
|
|||||||
assert.strictEqual(e, err);
|
assert.strictEqual(e, err);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
await (async () => {
|
||||||
|
console.log('iterating on an ended stream completes');
|
||||||
|
const r = new Readable({
|
||||||
|
objectMode: true,
|
||||||
|
read() {
|
||||||
|
this.push('asdf');
|
||||||
|
this.push('hehe');
|
||||||
|
this.push(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
for await (const a of r) {
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
for await (const b of r) {
|
||||||
|
}
|
||||||
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
// to avoid missing some tests if a promise does not resolve
|
// to avoid missing some tests if a promise does not resolve
|
||||||
|
Loading…
x
Reference in New Issue
Block a user