mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
stream: pass error on legacy destroy
PR-URL: https://github.com/nodejs/node/pull/43519 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
committed by
GitHub
parent
7cbcc4fc43
commit
51beb26a5f
@@ -319,7 +319,7 @@ function destroyer(stream, err) {
|
||||
// TODO: Don't lose err?
|
||||
stream.close();
|
||||
} else if (err) {
|
||||
process.nextTick(emitErrorCloseLegacy, stream);
|
||||
process.nextTick(emitErrorCloseLegacy, stream, err);
|
||||
} else {
|
||||
process.nextTick(emitCloseLegacy, stream);
|
||||
}
|
||||
|
||||
@@ -1526,3 +1526,33 @@ const tsp = require('timers/promises');
|
||||
assert.strictEqual(val, null);
|
||||
}));
|
||||
}
|
||||
|
||||
{
|
||||
// Mimics a legacy stream without the .destroy method
|
||||
class LegacyWritable extends Stream {
|
||||
write(chunk, encoding, callback) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
const writable = new LegacyWritable();
|
||||
writable.on('error', common.mustCall((err) => {
|
||||
assert.deepStrictEqual(err, new Error('stop'));
|
||||
}));
|
||||
|
||||
pipeline(
|
||||
Readable.from({
|
||||
[Symbol.asyncIterator]() {
|
||||
return {
|
||||
next() {
|
||||
return Promise.reject(new Error('stop'));
|
||||
}
|
||||
};
|
||||
}
|
||||
}),
|
||||
writable,
|
||||
common.mustCall((err) => {
|
||||
assert.deepStrictEqual(err, new Error('stop'));
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user