From 883512b10398cb47bab079de4f8fa87cfcb0fc1b Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Fri, 8 Sep 2017 15:28:05 -0400 Subject: [PATCH] Reload the page when an error has occurred Fixes #3096 --- packages/react-dev-utils/webpackHotDevClient.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/react-dev-utils/webpackHotDevClient.js b/packages/react-dev-utils/webpackHotDevClient.js index 18a6a4a0ae1..50ff451fc50 100644 --- a/packages/react-dev-utils/webpackHotDevClient.js +++ b/packages/react-dev-utils/webpackHotDevClient.js @@ -28,9 +28,18 @@ var ErrorOverlay = require('react-error-overlay'); ErrorOverlay.startReportingRuntimeErrors({ launchEditorEndpoint: launchEditorEndpoint, onError: function() { - // TODO: why do we need this? - if (module.hot && typeof module.hot.decline === 'function') { - module.hot.decline(); + // Ensure HotModuleReplacementPlugin is active + if (module.hot && typeof module.hot.addStatusHandler === 'function') { + // When a run time error occurs, it does not make sense to continue HMR; + // as application state may be corrupted. + // So, next time we check for updates, simply reload the page (to + // abort the process). + // See https://github.com/facebookincubator/create-react-app/issues/3096 + module.hot.addStatusHandler(function(status) { + if (status === 'check') { + window.location.reload(); + } + }); } }, filename: '/static/js/bundle.js',