Repository navigation
fix(web): reload tabs left on an older bundle after a deploy - #605
Merged
Merged
Conversation
Inertia had no asset version, so the server never told a tab that its bundle was out of date. A tab opened before a release kept navigating by XHR, and the first page whose chunk the new deploy no longer served failed: the chunk 404s, our vite:preloadError handler prevents Vite's rethrow, the import resolves to undefined, and the page resolver throws "Page not found: <component>" while the user is shown the "New version available" prompt. With the version set to the Vite digest, a stale tab's next GET visit gets a 409 and Inertia reloads it into the new bundle. Non-GET requests are still processed, so a form sent from a stale tab is not lost. During a rolling deploy pods of both versions answer, so a tab can be reloaded more than once until the rollout finishes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Sentry PALAD-AI-FRONTEND-F and -G:
Error: Page not found: Docs/DocsPageand…/Projects/McpServers/McpServersPage, both minutes after the 1.8.0 deploy, from tabs still running the 1.5.0 and 1.7.0 bundles. Both pages exist in every release.How it happens:
config.versionunset), so the server never tells a tab that its bundle is out of date. A tab opened before a release keeps navigating by XHR.vite:preloadErrorfires.shared/lib/preloadErrorReload.tsxcallspreventDefault()to show "New version available". Vite 8 then resolves the import toundefined(baseModule().catch(handlePreloadError)), and the Inertia page resolver throws "Page not found" as an unhandled rejection.What
config.version = ViteRuby.digest, as the inertia_rails installer template sets it. A stale tab's next GET visit gets409+X-Inertia-Locationand reloads into the new bundle. Non-GET requests are still processed, so a form sent from a stale tab is not lost.inertia_reload_only,inertia_load_deferred_props) send noX-Inertia-Version, so every partial reload in the suite would get a 409.test/integration/web/inertia_asset_version_test.rbcovers three cases: a stale GET gets 409, a current GET renders, and a stale POST is still saved.preloadErrorReloadprompt stays. It still covers chunks loaded within a page, not on a visit.Rollout note
The digest covers the image's
app/frontend, which the production image keeps (onlynode_modulesis removed), so it is identical on every pod of one image and stable across boots. During a rolling deploy, pods of both versions answer, so a tab can be reloaded more than once until the rollout finishes.Verification
rubocopis clean on the changed files.bin/rails runnerin development prints the same digest on two boots. In test the version isnil.check_allwas not run locally).🤖 Generated with Claude Code