Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b992962

Browse filesBrowse files
watildeaduh95
authored andcommitted
stream: ensuring cross-destruction in _duplexify to prevent leaks
PR-URL: #62824 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
1 parent 48bb51b commit b992962
Copy full SHA for b992962

2 files changed

+18-1Lines changed: 18 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/streams/duplexify.js‎

Copy file name to clipboardExpand all lines: lib/internal/streams/duplexify.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ function _duplexify(pair) {
334334
eos(r, (err) => {
335335
readable = false;
336336
if (err) {
337-
destroyer(r, err);
337+
destroyer(w, err);
338338
}
339339
onfinished(err);
340340
});
Collapse file

‎test/parallel/test-stream-duplex-from.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-duplex-from.js
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,3 +401,20 @@ function makeATestWritableStream(writeFunc) {
401401
assert.strictEqual(d.writable, false);
402402
}));
403403
}
404+
405+
// When the readable side errors, the error must propagate to the writable side.
406+
{
407+
const expectedErr = new Error('readable error');
408+
const r = new Readable({ read() {} });
409+
const w = new Writable({
410+
write(chunk, encoding, callback) { callback(); },
411+
});
412+
const d = Duplex.from({ readable: r, writable: w });
413+
d.on('error', common.mustCall((err) => {
414+
assert.strictEqual(err, expectedErr);
415+
}));
416+
w.on('error', common.mustCall((err) => {
417+
assert.strictEqual(err, expectedErr);
418+
}));
419+
r.destroy(expectedErr);
420+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.