diff options
author | Darshan Sen <raisinten@gmail.com> | 2021-06-21 21:50:27 +0530 |
---|---|---|
committer | Node.js GitHub Bot <github-bot@iojs.org> | 2021-07-05 15:17:28 +0000 |
commit | b2ae12d422584dab25ddd15e7468925038eba223 (patch) | |
tree | 1d62d0a37732ee54c9c9d1aef06be5097411c639 /lib | |
parent | 3590b5db5525190458923bb15918cc9b93db102d (diff) | |
download | node-new-b2ae12d422584dab25ddd15e7468925038eba223.tar.gz |
stream: throw on premature close in Readable[AsyncIterator]
Fixes: https://github.com/nodejs/node/issues/39086
Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/39117
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/internal/streams/readable.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/internal/streams/readable.js b/lib/internal/streams/readable.js index 7f6876599c..6eb07cdd4a 100644 --- a/lib/internal/streams/readable.js +++ b/lib/internal/streams/readable.js @@ -58,9 +58,10 @@ const { const { ERR_INVALID_ARG_TYPE, - ERR_STREAM_PUSH_AFTER_EOF, ERR_METHOD_NOT_IMPLEMENTED, - ERR_STREAM_UNSHIFT_AFTER_END_EVENT + ERR_STREAM_PREMATURE_CLOSE, + ERR_STREAM_PUSH_AFTER_EOF, + ERR_STREAM_UNSHIFT_AFTER_END_EVENT, } = require('internal/errors').codes; const { validateObject } = require('internal/validators'); @@ -1138,7 +1139,7 @@ async function* createAsyncIterator(stream, options) { } else if (endEmitted) { break; } else if (closeEmitted) { - break; + throw new ERR_STREAM_PREMATURE_CLOSE(); } else { await new Promise(next); } @@ -1152,7 +1153,6 @@ async function* createAsyncIterator(stream, options) { } finally { if (!errorThrown && opts.destroyOnReturn) { if (state.autoDestroy || !endEmitted) { - // TODO(ronag): ERR_PREMATURE_CLOSE? destroyImpl.destroyer(stream, null); } } |