fix: recover stale dynamic imports after frontend releases - #1802
jekabs-karklins with Copilot wants to merge 8 commits into
Conversation
Co-authored-by: jekabs-karklins <58165815+jekabs-karklins@users.noreply.github.com>
Scott-James-Hurley
left a comment
There was a problem hiding this comment.
Is there a way to test this locally?
| const { enqueueSnackbar } = useSnackbar(); | ||
|
|
||
| useEffect(() => { | ||
| const showError = () => { |
There was a problem hiding this comment.
Could this be called showPageLoadError or something more descriptive?
| import * as serviceWorker from './serviceWorker'; | ||
| import './i18n'; | ||
|
|
||
| const DYNAMIC_IMPORT_ERROR_EVENT = 'dynamic-import-error'; |
There was a problem hiding this comment.
This is already declared in App.tsx. Is there a way to declare it just once?
| .then((version) => { | ||
| buildVersion = version; | ||
| }) | ||
| .catch(() => {}); |
There was a problem hiding this comment.
This catch statement doesn't do anything. It could be useful to log that an error happened whilst trying to fetch the build version.
joeshannon
left a comment
There was a problem hiding this comment.
Looks like a nice change
| return response.text(); | ||
| }; | ||
|
|
||
| let buildVersion: string | undefined; |
There was a problem hiding this comment.
Just to check I understand this is it the case that this value is cached in the user's browser?
Does this not run every time the user opens the application? If that is the case would it actually be possible for a stale version number to be in this variable?
Description
This pull request addresses the issue of stale dynamic imports after frontend releases.
Motivation and Context
Our users experienced broken functionality after the new release of the frontend was made.

With this fix, upon the error of reading dynamic module it will check if the build number has changed. If yes it will immediatelly reload the window.
Otherwise the snackbar with error will be displayed

Changes
How Has This Been Tested?
Fixes Jira Issue
https://jira.ess.eu//browse/swap-5749
Depends On
Tests included/Docs Updated?