fix: recover from stale UI bundle after upgrade instead of showing 50X - #1619
Open
rstrzelecki-inne-projekty wants to merge 1 commit into
Open
rstrzelecki-inne-projekty wants to merge 1 commit into
rstrzelecki-inne-projekty wants to merge 1 commit into
Conversation
After an upgrade a tab that still runs the previous bundle requests hashed chunks that no longer exist. The router fell through to NoRoute and answered with index.html (200), so the browser tried to parse HTML as JavaScript, the lazy import failed and the route errorElement rendered the "HTTP 50X" page until the user hard-refreshed. - server: a missing file under /static answers 404 instead of index.html (both the embedded build and ANSWER_STATIC_PATH handlers) - ui: when a lazy page import fails, reload the tab once (guarded by a sessionStorage flag that is cleared after the next successful import) so the new index.html and chunks are picked up automatically 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0181uZ2px83HmPo3HKSEzWQR Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0181uZ2px83HmPo3HKSEzWQR
rstrzelecki-inne-projekty
pushed a commit
to rstrzelecki-inne-projekty/answer
that referenced
this pull request
Sep 15, 2026
…me as upstream PR apache#1619) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0181uZ2px83HmPo3HKSEzWQR
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.
Proposed Changes
Problem. After an upgrade, every browser tab that was opened before it still runs the previous UI bundle. When the user navigates to a route whose page chunk has not been loaded yet, the bundle requests the old hashed file (e.g.
/static/js/6487.02e56745.chunk.js), which no longer exists. gin'sStaticFSfalls through toNoRoute, which answers withindex.htmland HTTP 200, so the browser tries to parse HTML as JavaScript, the lazyimport()rejects and the routeerrorElementrenders the "HTTP 50X" error page. The API is fine the whole time; only a hard refresh fixes the tab, which is confusing for users right after every deploy.Changes.
internal/router/ui.go: a request for a missing file under/static/(honouringbaseURLPath) now answers 404 instead ofindex.html— in both the embedded-build handler and theANSWER_STATIC_PATHhandler. Unit test added (ui_test.go).ui/src/router/index.tsx: when the lazy page import fails, the tab reloads once (asessionStorageflag prevents a loop; it is cleared after the next successful import), so the newindex.htmland chunks are picked up automatically instead of showing the 50X page.How to reproduce: open the site, deploy a new build (chunk hashes change), then navigate in the old tab to a page you have not visited yet → "HTTP 50X". With this change the tab reloads itself and shows the page.
Tested on a production instance (2.0.2 + this patch): simulated by rewriting a chunk URL to a non-existent hash — the tab reloaded once and rendered the page; SPA routes (
/questions,/users/...) still getindex.html, existing assets still return 200.Checklist
go test ./internal/router/passespnpm lint/tsc --noEmitclean for the UI change🤖 Generated with Claude Code
https://claude.ai/code/session_0181uZ2px83HmPo3HKSEzWQR