-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
Add all
option
#353
Add all
option
#353
Conversation
This looks good to me (@tiagonapoli and I both contributed to this PR). Only one thing: could you add a test for the following? We have a
We then just need to wait for a code review from @sindresorhus. |
Added on |
Yes looks good! |
Is there really no way we can fix this without introducing an option? (Let’s think hard about that first) Execa already has way too many options. |
The core problem is that the Because it introduces that extra assumption for the user ( We went back and forth on this with @tiagonapoli but could not find an alternative. |
Tagging @tomsotte as well if he wants to weigh in since he worked on the initial feature. |
I agree with @ehmicky that the |
I agree with @tomsotte that the |
Can we make |
Unless I'm missing something, lazy instantiation is not possible because once data has been written to |
Any new thoughts on this matter? |
This requires a major release, but I would like for #351 to be resolved since this is a breaking change as well. |
Description
Fixes #350
Fixes #344
Currently, when
buffer
is set tofalse
,execa
wait for the process to finish,stdout
,stderr
andall
streams to finish. However, in order for the process to certainly finish, the user will have to consume or justresume
theall
stream, because ifall
is not consumed and the process is output intensive,all
, which is aPassThrough
stream, will block the process output pipeline, preventing the process to close. Soall
stream has to be consumed orresumed
andstdout
,stderr
can be optionally consumed.It does make more sense for the user, when
buffer=false
, to consume onlystderr
andstdout
, optionally consumingall
, but for this behavior,all
should be opt-in (ifall
is present, the user will have to consume it, otherwise the process may not finish), which makes sense in general, not only whenbuffer=false
: in case the user genuinely wants to useall
stream, he/she will opt-in for it.When
buffer=false
another change that makes more sense is just to wait for the process to finish and not wait for the output streams. The user will have to consume them anyway, otherwise the process may not finish, so why not mirrorchild_process
's behavior in this case and remove this complexity fromexeca
?So this PR proposes to make
all
opt-in, which is a breaking change, and fixes bugs reported on #350 whenbuffer=false
.Type of change
Faulty behavior this PR solves
These bugs were detailed in #350, but this is a summary of them and the code below is the reason to 1 and 2 (and the fact that execa waits for
stdout
,stderr
andall
stream promises to finish):execa/lib/stream.js
Lines 55 to 74 in 071a815
getStreamPromise
whenbuffer=false
. Currently, waiting for the end of stream is faulty: Theall
stream emits afinish
event, instead anend
event, becauseall
is aDuplex
, and itsWritable
part is in action (stdout
andstderr
are being piped into it), not itsReadable
part. Ifall
is not consumed,execa
never finishes because its waiting anend
orerror
event fromall
.stdio
,stderr
andall
stream promises never end.getStreamPromise
whenbuffer=false
, meaning listen to the correct events for stream completion. The following bug forces the user to consumeall
, because otherwise the process will never finish, sinceall
blocks the output pipeline. This is the cause to makeall
opt-in.