You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the callback version this is not a big issue because pipeline() returns the last stream, so the user could resume the returned stream.
pipeline(readable,passThrough,fn).resume();
In the promisified variant, pipeline() is just a wrapper that returns a promise that is fulfilled when the callback of the callback variant is called.
However the user could not be able to resume the returned stream because they might not have direct control on it. For example if the last entry is a generator.
In this case stream.pipeline() returns an internal PassThrough proxy that the user cannot resume so the promise returned by streamPromises.pipeline() might never be fulfilled.
A possible workaround is to resume the returned stream in the promisified variant.
diff --git a/lib/stream/promises.js b/lib/stream/promises.js
index 0db01a8b20..5bbadd43c5 100644
--- a/lib/stream/promises.js+++ b/lib/stream/promises.js@@ -23,13 +23,17 @@ function pipeline(...streams) {
signal = options.signal;
}
- pl(streams, (err, value) => {+ const stream = pl(streams, (err, value) => {
if (err) {
reject(err);
} else {
resolve(value);
}
}, { signal });
++ if (stream.readable) {+ stream.resume();+ }
});
}
The text was updated successfully, but these errors were encountered:
#40653 (comment)
@lpinca feel free to edit issue and fill out with your concern. Otherwise I will dig into this at some later point.
The
pipeline()
callback might never be called if the destination is aTransform
stream that is not read. Here is an example.In the callback version this is not a big issue because
pipeline()
returns the last stream, so the user could resume the returned stream.In the promisified variant,
pipeline()
is just a wrapper that returns a promise that is fulfilled when the callback of the callback variant is called.However the user could not be able to resume the returned stream because they might not have direct control on it. For example if the last entry is a generator.
In this case
stream.pipeline()
returns an internalPassThrough
proxy that the user cannot resume so the promise returned bystreamPromises.pipeline()
might never be fulfilled.A possible workaround is to resume the returned stream in the promisified variant.
The text was updated successfully, but these errors were encountered: