Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reload the page when an error has occurred #3098

Merged
merged 2 commits into from Sep 9, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions packages/react-dev-utils/webpackHotDevClient.js
Expand Up @@ -25,13 +25,17 @@ var launchEditorEndpoint = require('./launchEditorEndpoint');
var formatWebpackMessages = require('./formatWebpackMessages');
var ErrorOverlay = require('react-error-overlay');

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

function handleApplyUpdates(err, updatedModules) {
if (err || !updatedModules) {
if (err || !updatedModules || hadRuntimeError) {
window.location.reload();
return;
}
Expand Down