Skip to content
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);
Comment thread
ronag marked this conversation as resolved.
}
};
Comment thread
vadzim marked this conversation as resolved.

Expand Down