Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
nfischer merged 5 commits intomasterfromremove-codefile-param
Oct 31, 2017
Merged

Remove codeFile parameter#791

nfischer merged 5 commits intomasterfromremove-codefile-param
Oct 31, 2017

Conversation

@nfischer
Copy link
Member

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

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
@nfischernfischer added execIssues specific to the shell.exec() API refactor labelsOct 20, 2017
@nfischernfischer self-assigned thisOct 20, 2017
});
}catch(e){
// child_process could not run the command.
process.exit(127);
Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
MemberAuthor

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?

Copy link
Contributor

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);

Copy link
MemberAuthor

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:

  1. Send output to stdio in real-time
  2. Save that output in a file (for whenexec-child.js finishes)

If we pipe the output, then we can't achieve bullet 2.

Copy link
Contributor

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);

Copy link
MemberAuthor

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
Copy link
MemberAuthor

Comments are addressed, I'll look into the CI failures

@codecov-io
Copy link

codecov-io commentedOct 27, 2017
edited
Loading

Codecov Report

Merging#791 intomaster willincrease coverage by0.3%.
The diff coverage is100%.

Impacted file tree graph

@@            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
Impacted FilesCoverage Δ
src/exec.js97.89% <100%> (+0.52%)⬆️
src/exec-child.js100% <100%> (ø)⬆️
src/common.js98.79% <0%> (+0.46%)⬆️

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last update9e3f9ab...63b5e21. Read thecomment docs.

@nfischer
Copy link
MemberAuthor

@freitagbr this is ready for review (tests should pass, the last commit is just a comment)

@freitagbr
Copy link
Contributor

freitagbr commentedOct 27, 2017
edited
Loading

For reference, I found a few commits related to the{ end: false } option passed for the pipes:

The way we have it currently is basically identical to piping without{ end: false }, so I'm not sure if the original issues will crop up again. Perhaps it was an issue with node itself.

// child_process could not run the command.
/* istanbul ignore next */
process.exitCode=127;
}
Copy link
Contributor

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.

Copy link
MemberAuthor

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.

Copy link
Contributor

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.

Copy link
MemberAuthor

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.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Removed it.

Copy link
Contributor

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
Copy link
MemberAuthor

The way we have it currently is basically identical to piping without { end: false }, so I'm not sure if the original issues will crop up again. Perhaps it was an issue with node itself.

Thanks for researching. Looking back, we used to pipe stdout & stderr into the same file (externally visible asshell.exec().output). I changed thisa while back to separate the two streams (so we have.stdout and.stderr). Now that we have 2 readable streams piping into 2 writable streams, we can use default stream-closing behavior.

@nfischer
Copy link
MemberAuthor

@freitagbr I think everything is resolved.

@freitagbr
Copy link
Contributor

LGTM, I restarted the Travis builds for good measure.

@nfischer
Copy link
MemberAuthor

Travis had problems last night 😞

@nfischernfischer merged commit6189d7f intomasterOct 31, 2017
@nfischernfischer deleted the remove-codefile-param branchOctober 31, 2017 22:52
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@freitagbrfreitagbrfreitagbr approved these changes

Assignees

@nfischernfischer

Labels

execIssues specific to the shell.exec() APIrefactor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@nfischer@codecov-io@freitagbr

[8]ページ先頭

©2009-2025 Movatter.jp