mistercrunch commented on code in PR #28604:
URL: https://github.com/apache/superset/pull/28604#discussion_r1607063577


##########
superset-frontend/src/setup/setupApp.ts:
##########
@@ -87,6 +87,27 @@ export default function setupApp() {
         window.location.reload();
       });
     });
+    // Chuck errors fix: https://github.com/apache/superset/issues/28259
+    window.addEventListener('error', e => {
+      // prompt user to confirm refresh
+      if (/Loading chunk [\d]+ failed/.test(e.message)) {
+        alert(
+          'A new version released. Need to reload the page to apply changes.',
+        );
+        window.location.reload();
+      }
+    });
+    const origin = console.error;
+    console.error = error => {

Review Comment:
   Wait is monkey-patching `console.error` seems like a big no-no. Why is this 
necessary here? isn't the event-listener acting as expected?
   
   Other approaches I can think of - define and use our own `import()` function 
as say `importSupersetModule()` across the codebase, wrapping the usual import 
with some error handling(?)
   
   Creating some sort of React ErrorBoundary that does something similar?
   
   Also, would be great if we can use and antd modal instead of the native 
`alert()`...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to