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 1 commit
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
15 changes: 12 additions & 3 deletions packages/react-dev-utils/webpackHotDevClient.js
Expand Up @@ -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();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing this here, we may just want to replace all of this with a boolean we set to true, then check here:
https://github.com/facebookincubator/create-react-app/blob/fcb6dc55578e089e9f62f6e6c12cb9b60a57fee5/packages/react-dev-utils/webpackHotDevClient.js#L229-L233

/cc @gaearon

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effectively, if (err || !updatedModules || hadRuntimeError) {.

}
});
}
},
filename: '/static/js/bundle.js',
Expand Down