Skip to content

Commit 3c5ba31

Browse files
brandonesDaniel Figueiredo
authored and
Daniel Figueiredo
committed
Make build exit with error code when interrupted (facebook#1496)
* 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
1 parent ae147ff commit 3c5ba31

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/react-scripts/bin/react-scripts.js

+16
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ case 'test':
1313
[require.resolve('../scripts/' + script)].concat(args),
1414
{stdio: 'inherit'}
1515
);
16+
if (result.signal) {
17+
if (result.signal == 'SIGKILL') {
18+
console.log(
19+
'The build failed because the process exited too early. ' +
20+
'This probably means the system ran out of memory or someone called ' +
21+
'`kill -9` on the process.'
22+
);
23+
} else if (result.signal == 'SIGTERM') {
24+
console.log(
25+
'The build failed because the process exited too early. ' +
26+
'Someone might have called `kill` or `killall`, or the system could ' +
27+
'be shutting down.'
28+
);
29+
}
30+
process.exit(1);
31+
}
1632
process.exit(result.status);
1733
break;
1834
default:

0 commit comments

Comments
 (0)