- Notifications
You must be signed in to change notification settings - Fork744
Remove codeFile parameter#791
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This parameter isn't needed, we can easily rely on exit code status for this.Eliminating the parameter reduces file IO, code complexity, and removes a busyloop.Issue#782
src/exec-child.js Outdated
| }); | ||
| }catch(e){ | ||
| // child_process could not run the command. | ||
| process.exit(127); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
process.exit is potentially a bad idea if there are still callbacks in the queue, or if there are async tasks running, because they will not finish. Of course, at this point, neither of these should be the case, but I still think settingprocess.exitCode is a safer way to do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Also, below this, we are manually endingstdoutStream andstderrStream whenc.stdout andc.stderr end. Why do they need to be ended manually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ack onprocess.exitCode, sounds like it will be safer.
I'm not sure if we need to manually end the stream. This is legacy code. What would end the streams otherwise, though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I would need to test this to make sure, but just a normalpipe should work:
c.stdout.pipe(stdoutStream);c.stderr.pipe(stderrStream);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I don't think we can do that. We need things as-they-are in order to:
- Send output to stdio in real-time
- Save that output in a file (for when
exec-child.jsfinishes)
If we pipe the output, then we can't achieve bullet 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
You can just pipe twice:
c.stdout.pipe(fs.createWriteStream(stdoutFile));c.stderr.pipe(fs.createWriteStream(stderrFile));c.stdout.pipe(process.stdout);c.stderr.pipe(process.stderr);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Nevermind, I was confused. You're right 👍
nfischer commentedOct 27, 2017
Comments are addressed, I'll look into the CI failures |
codecov-io commentedOct 27, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov Report
@@ Coverage Diff @@## master #791 +/- ##=========================================+ Coverage 95.5% 95.81% +0.3%========================================= Files 34 34 Lines 1269 1361 +92 =========================================+ Hits 1212 1304 +92 Misses 57 57
Continue to review full report at Codecov.
|
nfischer commentedOct 27, 2017
@freitagbr this is ready for review (tests should pass, the last commit is just a comment) |
freitagbr commentedOct 27, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
For reference, I found a few commits related to the The way we have it currently is basically identical to piping without |
src/exec-child.js Outdated
| // child_process could not run the command. | ||
| /* istanbul ignore next */ | ||
| process.exitCode=127; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
IfchildProcess.exec throws, thenc will beundefined, right? That means the code below this try/catch will fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think you're right. We should actually think of valid cases which might trigger this and document them. I thinkmaxBuffer normally triggers this, but we're hitting themaxBuffer on theexecFileSync() call inexec.js first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Looking at the current code forchildProcess.exec, I'm not sure it can throw synchronous exceptions. Not sure about past versions of node, however.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Hmmm you may be right.
I tried adding all sorts of broken/invalid cases and couldn't actually trigger this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Removed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Just for the sake of verifying, I looked through the history ofchildProcess.exec and it hasn't changed much in 2 years, basically sincev0.12. So, it is safe to remove thetry/catch
nfischer commentedOct 28, 2017
Thanks for researching. Looking back, we used to pipe stdout & stderr into the same file (externally visible as |
nfischer commentedOct 31, 2017
@freitagbr I think everything is resolved. |
freitagbr commentedOct 31, 2017
LGTM, I restarted the Travis builds for good measure. |
nfischer commentedOct 31, 2017
Travis had problems last night 😞 |
This parameter isn't needed, we can easily rely on exit code status for this.
Eliminating the parameter reduces file IO, code complexity, and removes a busy
loop.
Issue#782