Skip to content

Commit

Permalink
Make build exit with error code when interrupted (facebook#1496)
Browse files Browse the repository at this point in the history
* Make build exit with error code when interrupted

This addresses issue facebook#1493.

Current behavior is that `npm run build` exits code 0 without creating a bundle when interrupted. This change makes the build script catch catchable interruptions and exit with the appropriate error code.

* Better error messages for kill signals

* Don't catch SIGINT

Ctrl+C should exit silently, and already produces a non-zero exit code when sent to the console while `npm run build` is running. Exit code 0 is produced if SIGINT is sent directly to the `node build.js` process, but this is unlikely to happen. A SIGINT handler in `build.js` will also be triggered by Ctrl+C in the console, potentially producing unnecessary noise.

* Style fix

* No changes needed to build.js

Problem is coming from the parent process, `react-scripts`

* Make react-scripts script handle signals

* Clarify context
  • Loading branch information
brandones authored and Daniel Figueiredo committed Feb 22, 2017
1 parent ae147ff commit 3c5ba31
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/react-scripts/bin/react-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ case 'test':
[require.resolve('../scripts/' + script)].concat(args),
{stdio: 'inherit'}
);
if (result.signal) {
if (result.signal == 'SIGKILL') {
console.log(
'The build failed because the process exited too early. ' +
'This probably means the system ran out of memory or someone called ' +
'`kill -9` on the process.'
);
} else if (result.signal == 'SIGTERM') {
console.log(
'The build failed because the process exited too early. ' +
'Someone might have called `kill` or `killall`, or the system could ' +
'be shutting down.'
);
}
process.exit(1);
}
process.exit(result.status);
break;
default:
Expand Down

0 comments on commit 3c5ba31

Please sign in to comment.