Skip to content
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

fork() does not emit 'error' if process creation fails #15734

Closed
rus0000 opened this issue Oct 2, 2017 · 3 comments
Closed

fork() does not emit 'error' if process creation fails #15734

rus0000 opened this issue Oct 2, 2017 · 3 comments
Labels
child_process Issues and PRs related to the child_process subsystem.

Comments

@rus0000
Copy link
Contributor

rus0000 commented Oct 2, 2017

Unlike spawn in fork on error is not executed.

const { fork } = require('child_process');
const subprocess = fork('bad_command');

subprocess.on('error', (err) => {
    console.log('Failed to start subprocess.', err);
});
@rus0000 rus0000 changed the title fork() do not emit 'error' if process creation fails fork() does not emit 'error' if process creation fails Oct 2, 2017
@mscdex mscdex added the child_process Issues and PRs related to the child_process subsystem. label Oct 2, 2017
@evanlucas
Copy link
Contributor

do you get the same error on v8.5.0?

@cjihrig
Copy link
Contributor

cjihrig commented Oct 2, 2017

The problem is that fork() spawns node, which works. The child process throws an exception when it tries to require() the module that does not exist. The child process exits with a non-zero status code.

@bnoordhuis
Copy link
Member

bnoordhuis commented Oct 2, 2017

What Colin said. I'll close this out as 'working as intended.' If anyone feels this ought to be documented, please open a documentation pull request.

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.
Projects
None yet
Development

No branches or pull requests

5 participants