mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6679] [MERGED] fix: recover panel navigation after stale chunk failures #6406
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#6406
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6679
Author: @mvanhorn
Created: 9/29/2026
Status: ✅ Merged
Merged: 10/2/2026
Merged by: @MHSanaei
Base:
main← Head:fix/6673-panel-stale-chunk-recovery📝 Commits (1)
8c0d09bfix: recover panel navigation after stale chunk failures📊 Changes
2 files changed (+310 additions, -0 deletions)
View changed files
📝
frontend/src/main.tsx(+26 -0)➕
frontend/src/test/chunk-recovery.test.tsx(+284 -0)📄 Description
Summary
Add a
vite:preloadErrorlistener directly infrontend/src/main.tsx, registered before the router is rendered, to reload the current URL once when a lazy chunk fails; preserve the custom panel base path, pathname, query, and fragment by usinglocation.reload(). Before reloading, persist a sessionStorage guard scoped to the panel base path and the current entry bundle URL (import.meta.url), and also mark the attempt in memory so concurrent chunk failures cannot schedule repeated reloads. Do not clear the persisted marker on bootstrap: a repeat failure from the same bundle must propagate normally, and inaccessible storage must fail safely without automatic reload; prevent the event's default behavior only when committing to the guarded reload.After upgrading to 3.8.5, the reporter sees React Router's default error screen when visiting Inbounds, Hosts, Outbound, and Routing because dynamically imported JavaScript chunks cannot be fetched. The automated analysis identifies stale entry code referencing removed hashed chunks, and a human contributor reports that the remote panel loads normally for them. Local
frontend/src/routes.tsxconfirms these pages use lazy imports and Outbound/Routing share XrayPage;internal/web/controller/dist.goalready serves HTML with no-store headers, while the service worker does not cache requests. Stale-tab recovery is a concrete local improvement, but the reporter has not confirmed that a refresh resolves their particular failure, so reproduce the upgrade scenario before claiming a complete fix.Closes #6673
Why
Add a
vite:preloadErrorlistener directly infrontend/src/main.tsx, registered before the router is rendered, to reload the current URL once when a lazy chunk fails; preserve the custom panel base path, pathname, query, and fragment by usinglocation.reload(). Before reloading, persist a sessionStorage guard scoped to the panel base path and the current entry bundle URL (import.meta.url), and also mark the attempt in memory so concurrent chunk failures cannot schedule repeated reloads. Do not clear the persisted marker on bootstrap: a repeat failure from the same bundle must propagate normally, and inaccessible storage must fail safely without automatic reload; prevent the event's default behavior only when committing to the guarded reload.Type of change
Areas affected
How was this tested?
A cancelable
vite:preloadErrorevent causes one reload and persists its guard before reloading; repeated events in the same document cause no additional reload.Re-import/bootstrap with the same entry identity and retained sessionStorage does not reload again on a persistent failure and leaves the error unsuppressed.
Another panel base path has its own guard, and a later entry bundle has a fresh recovery allowance; guard identity uses the actual production entry URL, not a development-only path.
Throwing storage reads or writes leave the normal error path intact and do not crash bootstrap or create a reload loop. Ordinary runtime errors and successful navigation do not trigger recovery.
In a real browser, open build A without visiting Inbounds/Hosts/Xray, replace the running server with build B whose lazy chunks changed, then navigate. Confirm the old chunk fails, the document reloads once, and the requested route succeeds under a non-root base path. Repeat with a persistently unavailable chunk and verify recovery stops once each encountered entry bundle has spent its allowance.
Write the focused Vitest regression first under the existing components/jsdom project; verify reload with a controlled browser global, not a new production injection interface. Run the focused test, then frontend typecheck, lint, format:check, test, build, and build-storybook; follow the repository's
make verifygate before submission and restart the Go server after rebuilding embedded HTML. Do not commit generated build output.Screenshots / recordings
No user-visible surface changes in this PR, so there is nothing to show.
Breaking changes
Covered in the summary above.
Checklist
go build ./...and the test suite pass locally.Not run: no test command resolved in this workspace, so nothing was executed to pass.
npm run lint,npm run typecheck, andnpm run buildpass.Not run: no test command resolved in this workspace, so nothing was executed to pass.
AI disclosure
AI was used for assistance.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.