In a user session on LogRocket I see that the user is experiencing an error page due to "TypeError: Failed to fetch dynamically imported module: https://itlist.com/resources/AffiliateDashboardPage-873a9baf.js"
The reason seems to be that the user was re-using a browser tab that loaded the app before the latest deployment, the hash of the resouces are changed, and the resource doesn’t load.
The user then reloaded the page and everything was fine.
Is there a way to circumvent the issue without having to manually reload the page? Could we automatically reload the page if a resource is not loading for example?
Tobbe
January 17, 2024, 5:57am
2
This is a known issue with no implemented fix yet
We’re tracking it here
opened 06:42PM - 27 Oct 23 UTC
bug/confirmed
topic/web
### What's not working?
We're seeing some errors in production like `TypeError:… Failed to fetch dynamically imported module: <url>`, where `<url>` will be something like `https://example.com/assets/ExamplePage-e948e32f.js`.
I suspect this mainly occurs on client navigation to a code-split page after a deployment where the chunk names have changed -- this looks like an issue with code splitting and "expected" chunks not being present in the newer deployment.
I'm not sure whether this would be considered a bug per se that redwood should handle out of the box, or whether this is up to each application to decide how to handle as a natural symptom of code splitting, so I was hoping to get some clarity on that if nothing else.
If it needs to be handled at the app level, I'm thinking catching the specific error on navigation and either "hard"-reloading or navigating to the destination path might be the way to go (depending on when exactly it occurs). I'm not sure yet if there are e.g. any navigation/router error hooks to tap into to that would simplify this.
I was also surprised to find no mention of this in any existing issues, so I'm not sure if this just isn't happening to others.
(FWIW I've also noticed what I think are similar errors in development since switching to vite in redwood 6, though the app seems to auto-reload when similar errors occur in development.)
### How do we reproduce the bug?
I don't have an exact repro yet; I'll update this section later if possible. But I think it's basically: deploy new version of app and attempt client side navigation to request a now-missing chunk.
### What's your environment? (If it applies)
```shell
Redwood 6.3.2
```
### Are you interested in working on this?
- [ ] I'm interested in working on this
Please add any extra input you might have to that issue thread
Thank you, I will try David’s workaround snippet, it’s exactly what I was looking for