-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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 test and docs update for detached fork process #24524
Conversation
@@ -0,0 +1,44 @@ | |||
// Copyright Joyent, Inc. and other Node contributors. |
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.
AFAIK this copyright is not needed for new tests.
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.
Will remove it. Thanks for letting me know.
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 suggest to use arrow functions wherever possible in file test/fixtures/parent-process-nonpersistent-fork.js
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.
SGTM with nits addressed.
@codegagan Thanks for the suggestion. I was following how they declared anonymous in other tests. Also do you mean |
2b18e03
to
30c5b2d
Compare
This comment has been minimized.
This comment has been minimized.
30c5b2d
to
d58c8ac
Compare
@vsemozhetbyt Thanks for catching that. I updated the commit message. I couldn't tell if I should use test or docs for the sub system. I also changed the docs so that is is less than 80 characters with indent preserved. |
cc @nodejs/child_process |
@vsemozhetbyt Looks like two of the checks failed. Not really sure what to make out of the details of the build. What is going on? |
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.
@nanomosfet you can look at this test file which has used arrow functions
1 Windows job failure may be unrelated. Let's rerun just this job: |
@vsemozhetbyt Nice it looks like that one passed. Is that a flaky test? Thank you BTW |
Flaky tests are usually marked as flaky in CI logs, but maybe we do not know yet that this one is flaky) |
@vsemozhetbyt I see. What is left to do so we can merge? I can change the anon. functions to arrow functions but I am afraid to because of rerunning the CI tests again. I can always make another PR to update a few test with arrow functions. I have noticed a lot of PR's where they are updating tests to use arrow functions. |
You can do this in another PR or just leave it for one of the Code-and-learn sessions (most of these latest PRs are from such session). Our rules require at least 48 hours for the review process and 2 approvals. So, for now, we just need to wait a bit) |
doc/api/child_process.md
Outdated
@@ -325,6 +325,8 @@ changes: | |||
* `args` {string[]} List of string arguments. | |||
* `options` {Object} | |||
* `cwd` {string} Current working directory of the child process. | |||
* `detached` {boolean} If `true`, prepares child to run |
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.
Probably better to duplicate the text that exists for the detached
option under spawn()
rather than have two different phrasings like 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.
Yeah I'd agree. It's almost the same though. I think the difference is just the If true
. Should I go ahead make that change?
process.on('exit', function() { | ||
assert.notStrictEqual(childId, -1); | ||
// Killing the child process should not throw an error | ||
process.kill(childId); |
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.
This strikes me as having significant potential for leaving stray processes around on CI. Not necessarily blocking, but surely something to keep an eye on after this lands....
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.
Yeah I totally agree. One of my checks was to make sure that no node processes were running after I ran the test individually.
I would prefer either leaving the functions as they are, or else changing them here. Changing them to arrow functions in a separate PR is just churn for no good reason. Again, not blocking. Just my own preference. |
This tests child process fork component in detached mode by spawning a parent process that creates a child process. We kill the parent process and check if the child is still running. Fixes: nodejs#17592
d58c8ac
to
f1f4837
Compare
@codegagan Updated PR to use arrow functions
@Trott - fork detached docs now match spwan detached. Both are now
Re ran test and no stray node processes Let me know what else I can do. Thank you for your time <3 :) Edit: also rebased to tip of nodejs/node |
Looks good to me. Can someone in @nodejs/child_process (or someone else knowledgable about potential pitfalls here) take a look? |
This tests child process fork component in detached mode by spawning a parent process that creates a child process. We kill the parent process and check if the child is still running. Fixes: nodejs#17592 PR-URL: nodejs#24524 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Landed in f051737. Thanks for the contribution! 🎉 (If you're interested in other possible contributions to Node.js but don't have a good idea of where to start looking, some ideas are posted at https://www.nodetodo.org/next-steps/.) |
This tests child process fork component in detached mode by spawning a parent process that creates a child process. We kill the parent process and check if the child is still running. Fixes: nodejs#17592 PR-URL: nodejs#24524 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesThis addresses issue #17592