child_process: add ChildProcess 'spawn' event#35369
child_process: add ChildProcess 'spawn' event#35369zenflow wants to merge 1 commit intonodejs:masterfrom
Conversation
|
The new event comes with the specification that, if emitted, it will come "before all other events and before any data is received via With this spec:
exampleconst { spawn } = require('child_process');
const { once } = require('events');
async function doSomethingWithChildProcess(){
const subprocess = spawn(...spawnArgs);
await once(subprocess, 'spawn');
// At this point we know the 'exit' event hasn't been emitted yet.
// We can expect it to be emitted in the future:
await once(subprocess, 'exit');
}
exampleconst { spawn } = require('child_process');
const { once } = require('events');
const streamToPromise = require('stream-to-promise');
async function doSomethingWithChildProcess(){
const subprocess = spawn(...spawnArgs);
await once(subprocess, 'spawn');
return streamToPromise(subprocess.stdout);
}Is this a good idea? Or should this spec be left out? |
|
Regarding the first item in the PR checklist: I can't check this because I haven't been able to run the whole test suite successfully, In both environments, various unrelated tests are failing (even without my changes applied). But the test I added & the test I updated are both passing and the If it's not super expensive, could we trigger the full CI run to verify the tests? |
|
(edit) Yup, it was just a flaky test. All the Github Actions are passing now. |
Commit Queue failed- Loading data for nodejs/node/pull/35369 ✔ Done loading data for nodejs/node/pull/35369 ----------------------------------- PR info ------------------------------------ Title child_process: add ChildProcess 'spawn' event (#35369) Author Matthew Francis Brunetti (@zenflow, first-time contributor) Branch zenflow:child-process-spawn-event -> nodejs:master Labels author ready, child_process, semver-minor Commits 2 - child_process: add ChildProcess 'spawn' event - doc: replace 'added' metadata for ChildProcess 'spawn' event with pla… Committers 2 - Matthew Francis Brunetti - GitHub PR-URL: https://github.com/nodejs/node/pull/35369 Fixes: https://github.com/nodejs/node/issues/35288 Reviewed-By: Anna Henningsen Reviewed-By: Gireesh Punathil ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/35369 Fixes: https://github.com/nodejs/node/issues/35288 Reviewed-By: Anna Henningsen Reviewed-By: Gireesh Punathil -------------------------------------------------------------------------------- ✔ Last GitHub Actions successful ℹ Last Full PR CI on 2020-10-15T12:01:43Z: https://ci.nodejs.org/job/node-test-pull-request/33642/ - Querying data for job/node-test-pull-request/33642/ ✔ Build data downloaded ✔ Last Jenkins CI successful ℹ This PR was created on Sun, 27 Sep 2020 04:30:44 GMT ✔ Approvals: 2 ✔ - Anna Henningsen (@addaleax): https://github.com/nodejs/node/pull/35369#pullrequestreview-498505074 ✔ - Gireesh Punathil (@gireeshpunathil) (TSC): https://github.com/nodejs/node/pull/35369#pullrequestreview-509300281 -------------------------------------------------------------------------------- ✔ No git cherry-pick in progress ✔ No git am in progress ✔ No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/master up to date... From https://github.com/nodejs/node * branch master -> FETCH_HEAD ✔ origin/master is now up-to-date - Downloading patch for 35369 From https://github.com/nodejs/node * branch refs/pull/35369/merge -> FETCH_HEAD ✔ Fetched commits as 0ca861745ad4..d3771c458cf4 -------------------------------------------------------------------------------- Auto-merging lib/internal/child_process.js Auto-merging doc/api/child_process.md warning: inexact rename detection was skipped due to too many files. warning: you may want to set your merge.renamelimit variable to at least 2606 and retry the command. [master 70e16da2ae] child_process: add ChildProcess 'spawn' event Author: Matthew Francis Brunetti Date: Sat Sep 26 05:02:55 2020 -0400 4 files changed, 51 insertions(+) create mode 100644 test/parallel/test-child-process-spawn-event.js Auto-merging doc/api/child_process.md warning: inexact rename detection was skipped due to too many files. warning: you may want to set your merge.renamelimit variable to at least 2606 and retry the command. [master 00c3842c02] doc: replace 'added' metadata for ChildProcess 'spawn' event with placeholder Author: Matthew Francis Brunetti Date: Sun Sep 27 15:00:07 2020 -0400 1 file changed, 1 insertion(+), 1 deletion(-) ✔ Patches applied There are 2 commits in the PR. Attempting autorebase. Rebasing (2/4) Commit Queue action: https://github.com/nodejs/node/actions/runs/332031152 |
|
The Commit Queue failed due to the title length of the second commit "doc: replace 'added' metadata for ChildProcess 'spawn' event with placeholder" (d3771c4) which was really just a fixup for the initial commit. I didn't realize it would be included as a separate commit when merged into master. @gireeshpunathil @aduh95 I will need to rewrite and force-push my branch to fix this, is that right? Also regarding that second commit, which was suggested by @mscdex here #35369 (comment): |
|
@zenflow - yes pls, if you can squash the commits, I will trigger the flow again or land it manually. |
The new event signals that the subprocess has spawned successfully and no 'error' event will be emitted from failing to spawn. Fixes: nodejs#35288
d3771c4 to
310c5db
Compare
|
CI run failed due to failed test for http2 on freebsd.. seems to be just an unrelated flaky test |
|
the only failure in |
Commit Queue failed- Loading data for nodejs/node/pull/35369 ✔ Done loading data for nodejs/node/pull/35369 ----------------------------------- PR info ------------------------------------ Title child_process: add ChildProcess 'spawn' event (#35369) Author Matthew Francis Brunetti (@zenflow, first-time contributor) Branch zenflow:child-process-spawn-event -> nodejs:master Labels author ready, child_process, semver-minor Commits 1 - child_process: add ChildProcess 'spawn' event Committers 1 - Matthew Francis Brunetti PR-URL: https://github.com/nodejs/node/pull/35369 Fixes: https://github.com/nodejs/node/issues/35288 Reviewed-By: Anna Henningsen Reviewed-By: Gireesh Punathil ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/35369 Fixes: https://github.com/nodejs/node/issues/35288 Reviewed-By: Anna Henningsen Reviewed-By: Gireesh Punathil -------------------------------------------------------------------------------- ⚠ Commits were pushed since the last review: ⚠ - child_process: add ChildProcess 'spawn' event ✔ Last GitHub Actions successful ℹ Last Full PR CI on 2020-10-28T05:58:29Z: https://ci.nodejs.org/job/node-test-pull-request/33895/ - Querying data for job/node-test-pull-request/33895/ ✔ Build data downloaded - Querying failures of job/node-test-commit/41694/ ✔ Data downloaded ✖ 1 failure(s) on the last Jenkins CI run ℹ This PR was created on Sun, 27 Sep 2020 04:30:44 GMT ✔ Approvals: 2 ✔ - Anna Henningsen (@addaleax): https://github.com/nodejs/node/pull/35369#pullrequestreview-498505074 ✔ - Gireesh Punathil (@gireeshpunathil) (TSC): https://github.com/nodejs/node/pull/35369#pullrequestreview-509300281 -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncu Commit Queue action: https://github.com/nodejs/node/actions/runs/333051293 |
|
😁 Thanks @gireeshpunathil for your help landing this! |
|
@gireeshpunathil I think this would be a great feature to have in v14. |
This replaces a placeholder that was added in the commit which added the new ChildProcess 'spawn' event. Refs: nodejs#35369
|
Yes, I guess so. |
Notable changes: child_process: * (SEMVER-MINOR) add ChildProcess 'spawn' event (Matthew Francis Brunetti) #35369 dns: * (SEMVER-MINOR) add setLocalAddress to Resolver (Josh Dague) #34824 http: * (SEMVER-MINOR) report request start and end with diagnostics_channel (Stephen Belanger) #34895 http2: * (SEMVER-MINOR) add updateSettings to both http2 servers (Vincent Boivin) #35383 lib: * (SEMVER-MINOR) create diagnostics_channel module (Stephen Belanger) #34895 src: * (SEMVER-MINOR) add --heapsnapshot-near-heap-limit option (Joyee Cheung) #33010 v8: * (SEMVER-MINOR) implement v8.stopCoverage() (Joyee Cheung) #33807 * (SEMVER-MINOR) implement v8.takeCoverage() (Joyee Cheung) #33807 worker: * (SEMVER-MINOR) add eventLoopUtilization() (Trevor Norris) #35664 PR-URL: TODO
Notable changes: child_process: * (SEMVER-MINOR) add ChildProcess 'spawn' event (Matthew Francis Brunetti) #35369 dns: * (SEMVER-MINOR) add setLocalAddress to Resolver (Josh Dague) #34824 http: * (SEMVER-MINOR) report request start and end with diagnostics_channel (Stephen Belanger) #34895 http2: * (SEMVER-MINOR) add updateSettings to both http2 servers (Vincent Boivin) #35383 lib: * (SEMVER-MINOR) create diagnostics_channel module (Stephen Belanger) #34895 src: * (SEMVER-MINOR) add --heapsnapshot-near-heap-limit option (Joyee Cheung) #33010 v8: * (SEMVER-MINOR) implement v8.stopCoverage() (Joyee Cheung) #33807 * (SEMVER-MINOR) implement v8.takeCoverage() (Joyee Cheung) #33807 worker: * (SEMVER-MINOR) add eventLoopUtilization() (Trevor Norris) #35664 PR-URL: #35948
Notable changes: child_process: * (SEMVER-MINOR) add ChildProcess 'spawn' event (Matthew Francis Brunetti) #35369 dns: * (SEMVER-MINOR) add setLocalAddress to Resolver (Josh Dague) #34824 http: * (SEMVER-MINOR) report request start and end with diagnostics_channel (Stephen Belanger) #34895 http2: * (SEMVER-MINOR) add updateSettings to both http2 servers (Vincent Boivin) #35383 lib: * (SEMVER-MINOR) create diagnostics_channel module (Stephen Belanger) #34895 src: * (SEMVER-MINOR) add --heapsnapshot-near-heap-limit option (Joyee Cheung) #33010 v8: * (SEMVER-MINOR) implement v8.stopCoverage() (Joyee Cheung) #33807 * (SEMVER-MINOR) implement v8.takeCoverage() (Joyee Cheung) #33807 worker: * (SEMVER-MINOR) add eventLoopUtilization() (Trevor Norris) #35664 PR-URL: #35948
Notable changes: child_process: * (SEMVER-MINOR) add ChildProcess 'spawn' event (Matthew Francis Brunetti) #35369 dns: * (SEMVER-MINOR) add setLocalAddress to Resolver (Josh Dague) #34824 http: * (SEMVER-MINOR) report request start and end with diagnostics_channel (Stephen Belanger) #34895 http2: * (SEMVER-MINOR) add updateSettings to both http2 servers (Vincent Boivin) #35383 lib: * (SEMVER-MINOR) create diagnostics_channel module (Stephen Belanger) #34895 src: * (SEMVER-MINOR) add --heapsnapshot-near-heap-limit option (Joyee Cheung) #33010 v8: * (SEMVER-MINOR) implement v8.stopCoverage() (Joyee Cheung) #33807 * (SEMVER-MINOR) implement v8.takeCoverage() (Joyee Cheung) #33807 worker: * (SEMVER-MINOR) add eventLoopUtilization() (Trevor Norris) #35664 PR-URL: #35948
Notable changes: child_process: * (SEMVER-MINOR) add ChildProcess 'spawn' event (Matthew Francis Brunetti) #35369 dns: * (SEMVER-MINOR) add setLocalAddress to Resolver (Josh Dague) #34824 http: * (SEMVER-MINOR) report request start and end with diagnostics_channel (Stephen Belanger) #34895 http2: * (SEMVER-MINOR) add updateSettings to both http2 servers (Vincent Boivin) #35383 lib: * (SEMVER-MINOR) create diagnostics_channel module (Stephen Belanger) #34895 src: * (SEMVER-MINOR) add --heapsnapshot-near-heap-limit option (Joyee Cheung) #33010 v8: * (SEMVER-MINOR) implement v8.stopCoverage() (Joyee Cheung) #33807 * (SEMVER-MINOR) implement v8.takeCoverage() (Joyee Cheung) #33807 worker: * (SEMVER-MINOR) add eventLoopUtilization() (Trevor Norris) #35664 PR-URL: #35948
The new event signals that the subprocess has spawned successfully and
no 'error' event will be emitted from failing to spawn.
Fixes: #35288
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesand/or benchmarksare includedchanged oraddedBig thanks to @bnoordhuis for his guidance & the actual changes to
lib/!