fix: Prevent reload loop with error on editor load

This commit is contained in:
Tom Moor
2020-08-10 15:52:45 -07:00
parent e9ce80a3aa
commit 0cac5cfe51
2 changed files with 10 additions and 6 deletions

View File

@ -8,6 +8,7 @@ import CenteredContent from "components/CenteredContent";
import HelpText from "components/HelpText"; import HelpText from "components/HelpText";
import PageTitle from "components/PageTitle"; import PageTitle from "components/PageTitle";
import { githubIssuesUrl } from "../../shared/utils/routeHelpers"; import { githubIssuesUrl } from "../../shared/utils/routeHelpers";
import env from "env";
type Props = { type Props = {
children: React.Node, children: React.Node,
@ -41,7 +42,7 @@ class ErrorBoundary extends React.Component<Props> {
render() { render() {
if (this.error) { if (this.error) {
const isReported = !!window.Sentry; const isReported = !!window.Sentry && env.DEPLOYMENT === "hosted";
return ( return (
<CenteredContent> <CenteredContent>

View File

@ -203,12 +203,15 @@ class DocumentScene extends React.Component<Props> {
const EditorImport = await import("./Editor"); const EditorImport = await import("./Editor");
this.editorComponent = EditorImport.default; this.editorComponent = EditorImport.default;
} catch (err) { } catch (err) {
console.error(err); if (err.message && err.message.match(/chunk/)) {
// If the editor bundle fails to load then reload the entire window. This // If the editor bundle fails to load then reload the entire window. This
// can happen if a deploy happens between the user loading the initial JS // can happen if a deploy happens between the user loading the initial JS
// bundle and the async-loaded editor JS bundle as the hash will change. // bundle and the async-loaded editor JS bundle as the hash will change.
window.location.reload(); window.location.reload();
return;
}
throw err;
} }
}; };