From 0cac5cfe511f533933a6280458bce382eadac39c Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 10 Aug 2020 15:52:45 -0700 Subject: [PATCH] fix: Prevent reload loop with error on editor load --- app/components/ErrorBoundary.js | 3 ++- app/scenes/Document/components/Document.js | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/components/ErrorBoundary.js b/app/components/ErrorBoundary.js index 739e8362c..ebd875d84 100644 --- a/app/components/ErrorBoundary.js +++ b/app/components/ErrorBoundary.js @@ -8,6 +8,7 @@ import CenteredContent from "components/CenteredContent"; import HelpText from "components/HelpText"; import PageTitle from "components/PageTitle"; import { githubIssuesUrl } from "../../shared/utils/routeHelpers"; +import env from "env"; type Props = { children: React.Node, @@ -41,7 +42,7 @@ class ErrorBoundary extends React.Component { render() { if (this.error) { - const isReported = !!window.Sentry; + const isReported = !!window.Sentry && env.DEPLOYMENT === "hosted"; return ( diff --git a/app/scenes/Document/components/Document.js b/app/scenes/Document/components/Document.js index d344a1b87..685b28b0c 100644 --- a/app/scenes/Document/components/Document.js +++ b/app/scenes/Document/components/Document.js @@ -203,12 +203,15 @@ class DocumentScene extends React.Component { const EditorImport = await import("./Editor"); this.editorComponent = EditorImport.default; } 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 + // 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. + window.location.reload(); + return; + } - // 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 - // bundle and the async-loaded editor JS bundle as the hash will change. - window.location.reload(); + throw err; } };