-
-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve promise returned by the .pipe()
methods
#745
Comments
👍 Looks like a good idea to me. I cannot think of any downsides. |
.pipe*()
methods.pipe()
methods
I have been working on this feature, and it appears that the Taking the following example:
All of the above is solved by requiring users not to do this: const destination = execa(...).pipe(execa(...)).pipe(execa(...))
const result = await destination But this instead: const source = execa(...)
const middle = execa(...)
const destination = execa(...)
const result = await source.pipe(middle).pipe(destination) This is more explicit, clearer and avoid the problems described above. In the majority of cases though, users only need the result, not the child process instance itself. With the new const result = await execa(...).pipe(execa(...)).pipe(execa(...)) |
Problem
The following currently results in an unhandled promise rejection:
That's because
.pipe()
returnsexeca('cat')
, so only the second child process isawait
ed, not the first one.Solution
.pipe()
shouldawait
both child processes instead of only the second one.The return value can still be the second child process, which is the current behavior.
The returned promise would still resolve with the second child process' result, which is also the current behavior.
Additionally, it would now set
result.pipedFrom
orerror.pipedFrom
with the first child process' result/error.Details
Would return:
When the second process fails,
error.pipedFrom
would contain the first process' result and output, which could be very useful for debugging.When the first process fails, its
error
would be propagated as is, since this is what actually failed.What do you think?
The text was updated successfully, but these errors were encountered: