Skip to content

Conversation

maclover7
Copy link
Contributor

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), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

errors, child_process

@nodejs-github-bot nodejs-github-bot added the child_process Issues and PRs related to the child_process subsystem. label Aug 24, 2017
@Trott Trott added semver-major PRs that contain breaking changes and should be released in the next major version. errors Issues and PRs related to JavaScript errors originated in Node.js core. labels Aug 24, 2017
Copy link
Member

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.

Copy link
Contributor Author

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 😞

Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

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'

Copy link
Contributor Author

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?

Copy link
Member

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'

Copy link
Member

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

Copy link
Member

@jasnell jasnell left a 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

@maclover7
Copy link
Contributor Author

@jasnell PTAL

@BridgeAR
Copy link
Member

Ping @jasnell
This could use some general LGs @nodejs/collaborators

@jasnell
Copy link
Member

jasnell commented Sep 15, 2017

Ping. this needs more @nodejs/tsc review.

Copy link
Member

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)

Copy link
Contributor

Choose a reason for hiding this comment

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

child process's

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed.

Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Member

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

Copy link
Member

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

Copy link
Member

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.

Copy link
Member

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

@BridgeAR
Copy link
Member

Ping @maclover7

@BridgeAR
Copy link
Member

@maclover7 do you still want to pursue this? There is overlapping PR that waits for this one to be merged.

@maclover7
Copy link
Contributor Author

@BridgeAR sorry for my delay -- working on addressing comments. make seems to be taking a little longer lately since lots of changes in master :)

Copy link
Member

@BridgeAR BridgeAR left a 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.

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

This should be removed.

@BridgeAR
Copy link
Member

@nodejs/tsc this needs some LGs

@BridgeAR BridgeAR requested a review from a team September 27, 2017 21:48
@joyeecheung
Copy link
Member

@BridgeAR
Copy link
Member

Copy link
Member

@BridgeAR BridgeAR left a 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.

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

@jasnell
Copy link
Member

jasnell commented Oct 30, 2017

@maclover7 ... should this be ready to go ?

@maclover7
Copy link
Contributor Author

@jasnell rebased and make test passing locally... I think CI plus another review should be all that's left?

@mcollina
Copy link
Member

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM

@maclover7
Copy link
Contributor Author

rebased, one last CI before landing: https://ci.nodejs.org/job/node-test-pull-request/11783/

@maclover7
Copy link
Contributor Author

New CI after fixing linter error: https://ci.nodejs.org/job/node-test-pull-request/11784/

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');
Copy link
Contributor

@apapirovski apapirovski Nov 28, 2017

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].)

@maclover7
Copy link
Contributor Author

maclover7 commented Nov 29, 2017

@apapirovski updated PTAL

@maclover7
Copy link
Contributor Author

Waiting for CI to wrap up: https://ci.nodejs.org/job/node-test-pull-request/11808/

@maclover7 maclover7 self-assigned this Nov 29, 2017
@maclover7
Copy link
Contributor Author

Landing

@maclover7
Copy link
Contributor Author

Landed in b1e6c0d

@maclover7 maclover7 closed this Nov 29, 2017
@maclover7 maclover7 deleted the jm-errors-childprocess branch November 29, 2017 23:57
maclover7 added a commit that referenced this pull request Nov 29, 2017
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

child_process Issues and PRs related to the child_process subsystem. errors Issues and PRs related to JavaScript errors originated in Node.js core. semver-major PRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.