diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index 69f249f22a330957aa308e472e0973959108fdeb..fe4ec959d4d41731e60f8e7047d92c9d9e243f1a 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -13,6 +13,13 @@ // Do this as the first thing so that any code reading it knows the right env. process.env.NODE_ENV = 'production'; +// Makes the script crash on unhandled rejections instead of silently +// ignoring them. In the future, promise rejections that are not handled will +// terminate the Node.js process with a non-zero exit code. +process.on('unhandledRejection', err => { + throw err; +}); + // Load environment variables from .env file. Suppress warnings using silent // if this file is missing. dotenv will never modify any environment variables // that have already been set. diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index 8edc441002ef593f41169e3a0496bfa1d97e45e9..e07a57ba5e7ded88d3920c588ed068cc89e012e9 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -9,6 +9,13 @@ */ 'use strict'; +// Makes the script crash on unhandled rejections instead of silently +// ignoring them. In the future, promise rejections that are not handled will +// terminate the Node.js process with a non-zero exit code. +process.on('unhandledRejection', err => { + throw err; +}); + const fs = require('fs-extra'); const path = require('path'); const spawnSync = require('cross-spawn').sync; diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index 9e2ea5cdcd03f5f70471e8388bf8dfc638c49eed..87d87e621e7274529363225a844d38c9e2e685a1 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -9,6 +9,13 @@ */ 'use strict'; +// Makes the script crash on unhandled rejections instead of silently +// ignoring them. In the future, promise rejections that are not handled will +// terminate the Node.js process with a non-zero exit code. +process.on('unhandledRejection', err => { + throw err; +}); + const fs = require('fs-extra'); const path = require('path'); const spawn = require('cross-spawn'); diff --git a/packages/react-scripts/scripts/start.js b/packages/react-scripts/scripts/start.js index 142a1f6d70528292b8b5c920ffb3a125bed1f4cd..12cce8ed313be03628475ebebcce13f4fd18325b 100644 --- a/packages/react-scripts/scripts/start.js +++ b/packages/react-scripts/scripts/start.js @@ -10,6 +10,13 @@ // @remove-on-eject-end 'use strict'; +// Makes the script crash on unhandled rejections instead of silently +// ignoring them. In the future, promise rejections that are not handled will +// terminate the Node.js process with a non-zero exit code. +process.on('unhandledRejection', err => { + throw err; +}); + process.env.NODE_ENV = 'development'; // Load environment variables from .env file. Suppress warnings using silent diff --git a/packages/react-scripts/scripts/test.js b/packages/react-scripts/scripts/test.js index e3a0094f982cc650b2bac50cbedd0ef4b9ec3086..5c395999d97b053514b4e8c2200cb5903499d18d 100644 --- a/packages/react-scripts/scripts/test.js +++ b/packages/react-scripts/scripts/test.js @@ -13,6 +13,13 @@ process.env.NODE_ENV = 'test'; process.env.PUBLIC_URL = ''; +// Makes the script crash on unhandled rejections instead of silently +// ignoring them. In the future, promise rejections that are not handled will +// terminate the Node.js process with a non-zero exit code. +process.on('unhandledRejection', err => { + throw err; +}); + // Load environment variables from .env file. Suppress warnings using silent // if this file is missing. dotenv will never modify any environment variables // that have already been set.