Skip to content

fix(web): reload tabs left on an older bundle after a deploy - #605

Merged
artempartos merged 1 commit into
developfrom
fix/inertia-asset-version
Oct 28, 2026
Merged

artempartos merged 1 commit into
developfrom
fix/inertia-asset-version

Conversation

@artempartos

Copy link
Copy Markdown
Contributor

Why

Sentry PALAD-AI-FRONTEND-F and -G: Error: Page not found: Docs/DocsPage and …/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:

  1. Inertia has no asset version (config.version unset), so the server never tells a tab that its bundle is out of date. A tab opened before a release keeps navigating by XHR.
  2. The first page whose chunk the new deploy no longer serves gets a 404, and vite:preloadError fires.
  3. shared/lib/preloadErrorReload.tsx calls preventDefault() to show "New version available". Vite 8 then resolves the import to undefined (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 gets 409 + X-Inertia-Location and reloads into the new bundle. Non-GET requests are still processed, so a form sent from a stale tab is not lost.
  • Off in test: the gem's own helpers (inertia_reload_only, inertia_load_deferred_props) send no X-Inertia-Version, so every partial reload in the suite would get a 409.
  • test/integration/web/inertia_asset_version_test.rb covers three cases: a stale GET gets 409, a current GET renders, and a stale POST is still saved.
  • The preloadErrorReload prompt 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 (only node_modules is 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

  • Locally, in a private test DB: the new test plus the sessions, features-shared-prop, profile (deferred props), projects and changelog tests. 73 runs, 0 failures. rubocop is clean on the changed files.
  • bin/rails runner in development prints the same digest on two boots. In test the version is nil.
  • The full suite runs on CI (check_all was not run locally).

🤖 Generated with Claude Code

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]>
@artempartos
artempartos merged commit 3d66488 into develop Oct 28, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant