diff --git a/lib/internal/streams/destroy.js b/lib/internal/streams/destroy.js index efa09e05eafef0..4f1873d974eca5 100644 --- a/lib/internal/streams/destroy.js +++ b/lib/internal/streams/destroy.js @@ -19,6 +19,7 @@ const { const kDestroy = Symbol('kDestroy'); const kConstruct = Symbol('kConstruct'); +function nop() {} function checkError(err, w, r) { if (err) { @@ -112,9 +113,7 @@ function _destroy(self, err, cb) { if (typeof then === 'function') { then.call( result, - function() { - process.nextTick(onDestroy, null); - }, + nop, function(err) { process.nextTick(onDestroy, err); }); diff --git a/test/parallel/test-stream-construct-async-error.js b/test/parallel/test-stream-construct-async-error.js index ea2d8740e29c94..952c7f25acce52 100644 --- a/test/parallel/test-stream-construct-async-error.js +++ b/test/parallel/test-stream-construct-async-error.js @@ -33,6 +33,7 @@ const assert = require('assert'); async _destroy(err, cb) { // eslint-disable-next-line no-restricted-syntax await setTimeout(common.platformTimeout(1)); + cb(err); } }