GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — stream: fix pipeline function tail deadlock · nodejs/node@9e889f4

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/stream
    • promises.js
  • test/parallel
    • test-stream-pipeline.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/stream/promises.js‎

Copy file name to clipboardExpand all lines: lib/stream/promises.js
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const {
4+
ArrayIsArray,
45
ArrayPrototypePop,
56
Promise,
67
} = primordials;
@@ -28,13 +29,22 @@ function pipeline(...streams) {
2829
end = options.end;
2930
}
3031

31-
pl(streams, (err, value) => {
32+
let lastStream = streams[streams.length - 1];
33+
if (streams.length === 1 && ArrayIsArray(streams[0])) {
34+
lastStream = streams[0][streams[0].length - 1];
35+
}
36+
37+
const stream = pl(streams, (err, value) => {
3238
if (err) {
3339
reject(err);
3440
} else {
3541
resolve(value);
3642
}
3743
}, { signal, end });
44+
45+
if (typeof lastStream === 'function' && stream.readable) {
46+
stream.resume();
47+
}
3848
});
3949
}
4050

Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-stream-pipeline.js
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,22 @@ tmpdir.refresh();
16571657
}));
16581658
}
16591659

1660+
{
1661+
async function* passThrough(source) {
1662+
for await (const chunk of source) {
1663+
yield chunk;
1664+
}
1665+
}
1666+
1667+
const streams = () => [
1668+
Readable.from(Array.from({ length: 100 }, (_, i) => i)),
1669+
passThrough,
1670+
];
1671+
1672+
pipelinep(...streams()).then(common.mustCall());
1673+
pipelinep(streams()).then(common.mustCall());
1674+
}
1675+
16601676
{
16611677
const r = new Readable();
16621678
for (let i = 0; i < 4000; i++) {

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.