Standard way of invalidating the client manifest after a new deploy #12951
Replies: 3 comments 2 replies
-
I think any navigation after a new deploy should cause a document request loading the new manifest again, so when RR loads a new manifest patch the server could include a header with the build version, if RR checks the build version is different it does a document reload. |
Beta Was this translation helpful? Give feedback.
-
Had a similar issue with Remix, but definitely more prevalent after the upgrade to v7. We keep a websocket open to our API server and have our deploy script broadcast an "update available" message. Our custom Link component will do a full page reload when clicking a link if it gets one of those messages. It helped reduce the crashes, but it's still super fragile. It doesn't cover form actions, and even for links there are instances where the websocket disconnects/reconnects cause missing update messages. An official approach from the RR team would definitely be helpful. |
Beta Was this translation helpful? Give feedback.
-
I think I'm experiencing a similar issue, but in the dev server environment. When I start the dev server and visit a route that hasn’t been fetched yet, it crashes. After a hard refresh, it works again. This seems related to how the client handles updates when the manifest changes, similar to what's being discussed here. I've had a hard time debugging this or getting suggested fixes to work—neither my attempt at the 'brute-force' approach mentioned in this discussion nor my attempt at applying this patch resolved it. Could this be a similar issue where the dev server is serving an outdated manifest or causing inconsistencies in module resolution? I’d really appreciate any guidance. Let me know if you need any details about my setup! |
Beta Was this translation helpful? Give feedback.
-
There's an issue has that seems to be cropping up after turning on Lazy Route Discovery which I outlined in Discord:
I didn't quite make the connection, but it perfectly explains the mistmatched context issues that I and other seem to be seeing.
Basically, the issue is in this step:
After a new deploy, it's entirely possible (and likely, even) that the entire chunking / code-splitting strategy has changed for the new set of static assets, resulting in React itself living in a new chunk.
When the patches get installed into the manifest, and the new module graph gets downloaded, you end up with two versions of React (and other things in your app that should be singletons now.. aren't).
This leads to a separate instance of
React.createContext()
being called, and since React context operates on referential identity, you end up withuseContext()
returningnull
when it shouldn't.The "brute force" band-aid for this issue is to tell
vite
to use stable chunk names for your dependencies, but it doesn't solve the underlying issue, which is that there needs to be some way to:Beta Was this translation helpful? Give feedback.
All reactions