Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream: fix handling generators in Readable.from #32844

Closed
Prev Previous commit
Next Next commit
fixup: make _destroy not async
  • Loading branch information
vadzim committed Apr 16, 2020
commit 7aac752bdbf39d23bd6a5d4448802fa37f7e6936
19 changes: 9 additions & 10 deletions lib/internal/streams/from.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,15 @@ function from(Readable, iterable, opts) {
}
};

readable._destroy = async function(error, cb) {
try {
if (needToClose) {
needToClose = false;
await close();
}
} catch (e) {
error = error || e;
} finally {
process.nextTick(cb, error);
readable._destroy = function(error, cb) {
if (needToClose) {
needToClose = false;
close().then(
() => process.nextTick(cb, error),
(e) => process.nextTick(cb, error || e),
);
} else {
cb(error);
ronag marked this conversation as resolved.
Show resolved Hide resolved
}
};
vadzim marked this conversation as resolved.
Show resolved Hide resolved

Expand Down