Skip to content

Commit 0ace417

Browse files
dbismutTimer
authored andcommitted
Make scripts crash on unhandled rejections (facebook#1819)
* Makes end-to-end testing crash on unhandled rejections * Comment fix
1 parent b3dc81d commit 0ace417

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

packages/react-scripts/scripts/build.js

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
// Do this as the first thing so that any code reading it knows the right env.
1414
process.env.NODE_ENV = 'production';
1515

16+
// Makes the script crash on unhandled rejections instead of silently
17+
// ignoring them. In the future, promise rejections that are not handled will
18+
// terminate the Node.js process with a non-zero exit code.
19+
process.on('unhandledRejection', err => {
20+
throw err;
21+
});
22+
1623
// Load environment variables from .env file. Suppress warnings using silent
1724
// if this file is missing. dotenv will never modify any environment variables
1825
// that have already been set.

packages/react-scripts/scripts/eject.js

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
*/
1010
'use strict';
1111

12+
// Makes the script crash on unhandled rejections instead of silently
13+
// ignoring them. In the future, promise rejections that are not handled will
14+
// terminate the Node.js process with a non-zero exit code.
15+
process.on('unhandledRejection', err => {
16+
throw err;
17+
});
18+
1219
const fs = require('fs-extra');
1320
const path = require('path');
1421
const spawnSync = require('cross-spawn').sync;

packages/react-scripts/scripts/init.js

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
*/
1010
'use strict';
1111

12+
// Makes the script crash on unhandled rejections instead of silently
13+
// ignoring them. In the future, promise rejections that are not handled will
14+
// terminate the Node.js process with a non-zero exit code.
15+
process.on('unhandledRejection', err => {
16+
throw err;
17+
});
18+
1219
const fs = require('fs-extra');
1320
const path = require('path');
1421
const spawn = require('cross-spawn');

packages/react-scripts/scripts/start.js

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
// @remove-on-eject-end
1111
'use strict';
1212

13+
// Makes the script crash on unhandled rejections instead of silently
14+
// ignoring them. In the future, promise rejections that are not handled will
15+
// terminate the Node.js process with a non-zero exit code.
16+
process.on('unhandledRejection', err => {
17+
throw err;
18+
});
19+
1320
process.env.NODE_ENV = 'development';
1421

1522
// Load environment variables from .env file. Suppress warnings using silent

packages/react-scripts/scripts/test.js

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
process.env.NODE_ENV = 'test';
1414
process.env.PUBLIC_URL = '';
1515

16+
// Makes the script crash on unhandled rejections instead of silently
17+
// ignoring them. In the future, promise rejections that are not handled will
18+
// terminate the Node.js process with a non-zero exit code.
19+
process.on('unhandledRejection', err => {
20+
throw err;
21+
});
22+
1623
// Load environment variables from .env file. Suppress warnings using silent
1724
// if this file is missing. dotenv will never modify any environment variables
1825
// that have already been set.

0 commit comments

Comments
 (0)