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 e60d905

Browse filesBrowse files
ronagRafaelGSS
authored andcommitted
stream: fix duplexify premature destroy
The duplexified Duplex should be autoDestroyed instead of prematurely destroyed when the readable and writable sides have finished without error. Fixes: #44925 PR-URL: #45133 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
1 parent 58bec56 commit e60d905
Copy full SHA for e60d905

File tree

Expand file treeCollapse file tree

2 files changed

+22
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+22
-3
lines changed
Open diff view settings
Collapse file

‎lib/internal/streams/duplexify.js‎

Copy file name to clipboardExpand all lines: lib/internal/streams/duplexify.js
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,6 @@ function _duplexify(pair) {
262262
cb(err);
263263
} else if (err) {
264264
d.destroy(err);
265-
} else if (!readable && !writable) {
266-
d.destroy();
267265
}
268266
}
269267

Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-stream-duplex-from.js
+22-1Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const common = require('../common');
44
const assert = require('assert');
5-
const { Duplex, Readable, Writable, pipeline } = require('stream');
5+
const { Duplex, Readable, Writable, pipeline, PassThrough } = require('stream');
66
const { Blob } = require('buffer');
77

88
{
@@ -278,3 +278,24 @@ const { Blob } = require('buffer');
278278

279279
duplex.write('test');
280280
}
281+
282+
{
283+
const through = new PassThrough({ objectMode: true });
284+
285+
let res = '';
286+
const d = Readable.from(['foo', 'bar'], { objectMode: true })
287+
.pipe(Duplex.from({
288+
writable: through,
289+
readable: through
290+
}));
291+
292+
d.on('data', (data) => {
293+
d.pause();
294+
setImmediate(() => {
295+
d.resume();
296+
});
297+
res += data;
298+
}).on('end', common.mustCall(() => {
299+
assert.strictEqual(res, 'foobar');
300+
})).on('close', common.mustCall());
301+
}

0 commit comments

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