-
Notifications
You must be signed in to change notification settings - Fork 30k
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: pass error on legacy destroy #43519
Conversation
Review requested:
|
This needs a test |
f629df5
to
10be672
Compare
@mscdex I came out (about tests) with this:
{
// 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'));
})
);
} I have to say that this is a very specific edge case. The only way to trigger the bug is to use either |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test looks fine (it's indeed an edge case but the test is needed to make sure we don't cause a regression in the future)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Landed in 51beb26 |
PR-URL: #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>
While looking at readable-stream source, I've found a possible missed argument while emitting an error toward legacy streams.
make lint
passes.make -j4 test
(UNIX), orvcbuild test
(Windows) passes.