-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
errors, child_process: use more internal/errors codes #14998
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
Conversation
lib/child_process.js
Outdated
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 one feels super odd to me... will think about this a bit more.
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.
Felt odd to me too, and still mulling over how to properly present this state to users 😞
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.
Shouldn't this be a ERR_INVALID_ARG_TYPE
though? Judging from the code below I would say it's options
that has the wrong type?
lib/child_process.js
Outdated
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 a more specific error is better for this.
e.g. new errors.Error('ERR_CHILD_PROCESS_IPC_REQUIRED')
with the original error message in tact.
lib/child_process.js
Outdated
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 make this a RangeError
with a specific (slightly improved) error message... e.g.
new errors.RangeError('ERR_CHILD_PROCESS_STDOUT_MAXBUFFER') // 'stdout maxBuffer length exceeded'
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.
Would have to create ERR_CHILD_PROCESS_STDERR_MAXBUFFER
in addition to ERR_CHILD_PROCESS_STDOUT_MAXBUFFER
, is this ok?
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.
Or create a single ERR_CHILD_PROCESS_STDIO_MAXBUFFER that takes a single argument specifying 'stdout' or '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.
It's now possible to combine these into ...
common.expectsError(() => fork(...), { code: 'ERR_INVALID_OPT_VALUE', type: TypeError });
etc
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 is definitely heading in the right direction! Thank you so very much! I've left a few comments and will do another thorough review a bit later
@jasnell PTAL |
Ping @jasnell |
Ping. this needs more @nodejs/tsc review. |
lib/child_process.js
Outdated
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.
IIUC the error message would be The value "['file', [], '']" is invalid for option "args"
if we do execFile('file', [], '')
, but then those are all the arguments, not args
(which is []
in this case)
doc/api/errors.md
Outdated
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.
child process's
lib/child_process.js
Outdated
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.
Nit: A template literal would be better here I guess.
lib/child_process.js
Outdated
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.
The old error message seems okay to me.
lib/child_process.js
Outdated
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.
Not needed.
lib/child_process.js
Outdated
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.
Not needed.
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.
Is this intentional? What happens now if the error is thrown like in the old test?
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 making an observation. This is the only place in this patch where expectsError
is explicitly passed 1
.
lib/child_process.js
Outdated
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 should be ERR_INVALID_ARG_TYPE
lib/child_process.js
Outdated
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 should be ERR_INVALID_ARG_TYPE
lib/child_process.js
Outdated
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 think this should be a RangeError
.
lib/child_process.js
Outdated
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 is a RangeError
as well
Ping @maclover7 |
@maclover7 do you still want to pursue this? There is overlapping PR that waits for this one to be merged. |
@BridgeAR sorry for my delay -- working on addressing comments. |
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.
Overall LGTM but the the commented code should be removed.
lib/internal/errors.js
Outdated
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.
Nit - to keep it consistent with the other types it should use %s maxBuffer length exceeded
. That is not blocking 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.
This should be removed.
@nodejs/tsc this needs some LGs |
Rerun of the CI https://ci.nodejs.org/job/node-test-pull-request/10304/ |
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.
LGTM and this is ready to land besides the failing Windows test.
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.
On Windows there are only 36 entries because a couple tests are not run on Windows.
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.
@maclover7 ... should this be ready to go ? |
@jasnell rebased and |
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.
LGTM
rebased, one last CI before landing: https://ci.nodejs.org/job/node-test-pull-request/11783/ |
New CI after fixing linter error: https://ci.nodejs.org/job/node-test-pull-request/11784/ |
lib/internal/errors.js
Outdated
E('ERR_CANNOT_WATCH_SIGINT', 'Cannot watch for SIGINT signals'); | ||
E('ERR_CHILD_CLOSED_BEFORE_REPLY', 'Child closed before reply received'); | ||
E('ERR_CHILD_PROCESS_IPC_REQUIRED', | ||
'Forked processes must have an IPC channel, %s is %s'); |
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 is used in one place, it doesn't feel like %s is %s
is really that helpful. It should probably just say something like Forked processes must have an IPC channel, missing value 'ipc' in %s
.
(This accepts an array so the %s
would be [value, value, value]
.)
@apapirovski updated PTAL |
Waiting for CI to wrap up: https://ci.nodejs.org/job/node-test-pull-request/11808/ |
Landing |
Landed in b1e6c0d |
PR-URL: #14998 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
Converts more (I believe this is all that is remaining?) of
child_process
to new-errors
-land. Most of this diff is straight copy and replace, so I don't think it's too intimidating. There are a few TODOs left in this PR on purpose that require some discussion, so I would appreciate any feedback on those.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
errors, child_process