Commit e19b0f63 authored by Brandon Istenes's avatar Brandon Istenes Committed by Dan Abramov
Browse files

Make build exit with error code when interrupted (#1496)

* Make build exit with error code when interrupted

This addresses issue #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
parent 7a02f9a4
No related merge requests found
Showing with 16 additions and 0 deletions
+16 -0
...@@ -13,6 +13,22 @@ case 'test': ...@@ -13,6 +13,22 @@ case 'test':
[require.resolve('../scripts/' + script)].concat(args), [require.resolve('../scripts/' + script)].concat(args),
{stdio: 'inherit'} {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); process.exit(result.status);
break; break;
default: default:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment