You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "mistercrunch (via GitHub)" <gi...@apache.org> on 2024/05/20 17:36:11 UTC
Re: [PR] fix: added events listeners to fix chunk error #28259 [superset]
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org