Skip to content

Commit 5786537

Browse files
Timerkasperpeulen
authored andcommitted
Reload the page when an error has occurred (facebook#3098)
* Reload the page when an error has occurred Fixes facebook#3096 * Use a global boolean instead
1 parent f3defb9 commit 5786537

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

packages/react-dev-utils/webpackHotDevClient.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ var launchEditorEndpoint = require('./launchEditorEndpoint');
2525
var formatWebpackMessages = require('./formatWebpackMessages');
2626
var ErrorOverlay = require('react-error-overlay');
2727

28+
// We need to keep track of if there has been a runtime error.
29+
// Essentially, we cannot guarantee application state was not corrupted by the
30+
// runtime error. To prevent confusing behavior, we forcibly reload the entire
31+
// application. This is handled below when we are notified of a compile (code
32+
// change).
33+
// See https://github.com/facebookincubator/create-react-app/issues/3096
34+
var hadRuntimeError = false;
2835
ErrorOverlay.startReportingRuntimeErrors({
2936
launchEditorEndpoint: launchEditorEndpoint,
3037
onError: function() {
31-
// TODO: why do we need this?
32-
if (module.hot && typeof module.hot.decline === 'function') {
33-
module.hot.decline();
34-
}
38+
hadRuntimeError = true;
3539
},
3640
filename: '/static/js/bundle.js',
3741
});
@@ -227,7 +231,7 @@ function tryApplyUpdates(onHotUpdateSuccess) {
227231
}
228232

229233
function handleApplyUpdates(err, updatedModules) {
230-
if (err || !updatedModules) {
234+
if (err || !updatedModules || hadRuntimeError) {
231235
window.location.reload();
232236
return;
233237
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy