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 d3449ca

Browse filesBrowse files
debadree25MoLow
authored andcommitted
stream: prevent pipeline hang with generator functions
Fixes: #47708 PR-URL: #47712 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Feng Yu <F3n67u@outlook.com>
1 parent 8ca50b6 commit d3449ca
Copy full SHA for d3449ca

File tree

Expand file treeCollapse file tree

2 files changed

+19
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-2
lines changed
Open diff view settings
Collapse file

‎lib/internal/streams/pipeline.js‎

Copy file name to clipboardExpand all lines: lib/internal/streams/pipeline.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,9 @@ async function pumpToNode(iterable, writable, finish, { end }) {
138138

139139
if (end) {
140140
writable.end();
141+
await wait();
141142
}
142143

143-
await wait();
144-
145144
finish();
146145
} catch (err) {
147146
finish(error !== err ? aggregateTwoErrors(error, err) : err);
Collapse file

‎test/parallel/test-stream-pipeline.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-pipeline.js
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,3 +1616,21 @@ const tsp = require('timers/promises');
16161616
dup.push(null);
16171617
dup.read();
16181618
}
1619+
1620+
{
1621+
let res = '';
1622+
const writable = new Writable({
1623+
write(chunk, enc, cb) {
1624+
res += chunk;
1625+
cb();
1626+
}
1627+
});
1628+
pipelinep(async function*() {
1629+
yield 'hello';
1630+
await Promise.resolve();
1631+
yield 'world';
1632+
}, writable, { end: false }).then(common.mustCall(() => {
1633+
assert.strictEqual(res, 'helloworld');
1634+
assert.strictEqual(writable.closed, false);
1635+
}));
1636+
}

0 commit comments

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