mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #3372] [MERGED] fix(client): auto-recover from stale-chunk dynamic-import failures #5907
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#5907
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/Pasta-Devs/Marinara-Engine/pull/3372
Author: @kolacheee
Created: 7/8/2026
Status: ✅ Merged
Merged: 7/8/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/3370-preload-error-recovery📝 Commits (3)
30b7cc2fix(client): auto-recover from stale-chunk dynamic-import failures (#3370)3d06b94Merge branch 'staging' into fix/3370-preload-error-recovery0d5b4d0fix(client): fall back after preload recovery failure📊 Changes
2 files changed (+45 additions, -0 deletions)
View changed files
📝
packages/client/src/lib/browser-runtime.ts(+40 -0)📝
packages/client/src/main.tsx(+5 -0)📄 Description
Linked issue
Closes #3370
Why this change
Lazy routes are code-split (
CharacterEditor = lazy(() => import(...))) and the PWA precaches the JS chunks (registerType: "autoUpdate",globPatterns: ["**/*.{js,css,…}"]). After an update, a still-running page — or a sticky service-worker precache — can reference a hashed chunk the new build already deleted (clean:stale-clientremoves old hashes). The lazyimport()then 404s and surfaces:There's no recovery for this: the app only auto-heals on a health-check version mismatch (
recoverFromVersionSkew), which a bare chunk-load failure doesn't trigger (client and server can report the same version yet a sticky SW still serves a stale chunk). So users hit it repeatedly across updates until they manually clear the service worker / site data.What changed
packages/client/src/lib/browser-runtime.ts— addregisterPreloadErrorRecovery(), avite:preloadErrorwindow listener that reuses the existingforceRefreshSparecovery (unregister the service worker, clear caches, reload with a cache-busting query param — the same thing the version-skew path already does). Guarded by a short sessionStorage cooldown (20 s) so a genuinely broken build — or a page that re-triggers the same import right after reload — can't reload-loop: after one attempt within the window,preventDefaultis skipped so Vite rethrows and the app's recovery boundary shows its Reload button.packages/client/src/main.tsx— callregisterPreloadErrorRecovery()at startup.Client-only; no server / shared / schema changes.
Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
pnpm --filter @marinara-engine/client build,pnpm --filter @marinara-engine/client lint.window.dispatchEvent(new Event("vite:preloadError", { cancelable: true }))→ the page should clear caches/SW and reload with a?chunk_reload=…param (check the URL after reload, and Application → Service Workers / Cache Storage are cleared).sessionStorage.getItem("mari-preload-recovery-at").pnpm build), then open the Character editor in the stale tab → instead of the "Failed to fetch dynamically imported module" error, the app should reload once and recover.Docs and release impact
Robustness fix; no docs or version impact.
UI evidence (if applicable)
N/A — startup recovery hook; no visual change (it replaces an error screen with a one-time reload).
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.