Repository navigation
fix(chunks): let Safari recover from a module that failed to load - #335
Conversation
Safari keeps a module that failed to load, across reloads, until a plain request for its URL succeeds. The stale-chunk reload and TanStack Router's own reload both landed on that same failure, so the page ended on the error screen, or blank, with no tab bar: the Reels flake on mobile-safari, and the "Importing a module script failed." errors Safari visitors report. Before it reloads, the page now asks every module it knows again. The error never names the failed module, and the healthy ones answer from the cache. The reload is stamped only once it really happens, so a document that TanStack reloaded first can still heal itself.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📦 Startup JS · ✅ Within budgetBrotli · 33 routes · against main at
What moved
Caution Far from the goal. 🟩 is the goal, each 🟥 one more goal’s worth.
📋 Every route
🤖 Agent briefWhat this measures. The Brotli size of each JS file the server-rendered page of a route modulepreloads, read from the TanStack Start manifest of Rules. Budgets live in Reproduce pnpm run build:e2e
gh run download 46654769743 --name bundle-size --dir /tmp/main-bundle-size
git show origin/main:bundle-budget.json > /tmp/main-budget.json
pnpm run bundle-size --base /tmp/main-bundle-size/report.json --base-budget /tmp/main-budget.json
pnpm run build:analyzeData {
"verdict": "pass",
"base": {
"commit": "b2f8b84",
"runId": "46654769743"
},
"violations": [],
"raisedBudgets": [],
"routeChanges": [
{
"name": "/reels",
"beforeBytes": 381900,
"afterBytes": 382174
},
{
"name": "/admin/downloader",
"beforeBytes": 374774,
"afterBytes": 375048
},
{
"name": "/admin/services",
"beforeBytes": 350761,
"afterBytes": 351035
},
{
"name": "/embed/$memeId",
"beforeBytes": 361027,
"afterBytes": 361301
},
{
"name": "/",
"beforeBytes": 446387,
"afterBytes": 446661
},
{
"name": "/admin",
"beforeBytes": 372610,
"afterBytes": 372884
},
{
"name": "/dmca",
"beforeBytes": 420687,
"afterBytes": 420961
},
{
"name": "/mentions-legales",
"beforeBytes": 420690,
"afterBytes": 420964
},
{
"name": "/privacy",
"beforeBytes": 420688,
"afterBytes": 420962
},
{
"name": "/terms-of-use",
"beforeBytes": 420689,
"afterBytes": 420963
},
{
"name": "/verify-email",
"beforeBytes": 441391,
"afterBytes": 441665
},
{
"name": "/memes/$memeId",
"beforeBytes": 497067,
"afterBytes": 497341
},
{
"name": "/admin/activity/$ip",
"beforeBytes": 375186,
"afterBytes": 375460
},
{
"name": "/admin/library/$memeId",
"beforeBytes": 488265,
"afterBytes": 488539
},
{
"name": "/admin/users/$userId",
"beforeBytes": 397735,
"afterBytes": 398009
},
{
"name": "/app",
"beforeBytes": 429838,
"afterBytes": 430112
},
{
"name": "/admin/activity",
"beforeBytes": 374464,
"afterBytes": 374738
},
{
"name": "/admin/ai-search",
"beforeBytes": 365619,
"afterBytes": 365893
},
{
"name": "/admin/categories",
"beforeBytes": 407409,
"afterBytes": 407683
},
{
"name": "/admin/library",
"beforeBytes": 409093,
"afterBytes": 409367
},
{
"name": "/admin/proposals",
"beforeBytes": 376872,
"afterBytes": 377146
},
{
"name": "/admin/users",
"beforeBytes": 387194,
"afterBytes": 387468
},
{
"name": "/checkout/success",
"beforeBytes": 415187,
"afterBytes": 415461
},
{
"name": "/memes/ai-search",
"beforeBytes": 466759,
"afterBytes": 467033
},
{
"name": "/password/create-new",
"beforeBytes": 454345,
"afterBytes": 454619
},
{
"name": "/password/reset",
"beforeBytes": 452663,
"afterBytes": 452937
},
{
"name": "/memes/$memeId/studio",
"beforeBytes": 516485,
"afterBytes": 516759
},
{
"name": "/memes/bookmarks",
"beforeBytes": 447938,
"afterBytes": 448212
},
{
"name": "/faq",
"beforeBytes": 415514,
"afterBytes": 415788
},
{
"name": "/pricing",
"beforeBytes": 428497,
"afterBytes": 428771
},
{
"name": "/settings",
"beforeBytes": 465635,
"afterBytes": 465909
},
{
"name": "/submit",
"beforeBytes": 456232,
"afterBytes": 456506
},
{
"name": "/memes/category/$slug",
"beforeBytes": 447080,
"afterBytes": 447354
}
],
"chunkChanges": [
{
"chunk": "index",
"deltaBytes": 274,
"loadedBy": [
"every route"
],
"isRegression": true
}
]
} |
Summary
Safari (WebKit) remembers a module that failed to load, across reloads, until a plain request for its URL succeeds. The stale-chunk reload and TanStack Router's own reload both landed on the same failure, and the page ended on the error screen, or blank, with no tab bar. Chromium asks for the module again and recovers on its own.
That is the
phone-journeyReels flake onmobile-safari, and the sameTypeError: Importing a module script failed.that Safari visitors report in production.on(vite:preloadError) if reloading, leaving the page, or reloaded in the last minute return + ask every module of the page again # healthy ones answer from the cache stamp the reload reloadThe error never names the module, so every same-origin
/assets/*.jsthe page knows (resource timing,modulepreloadlinks, module scripts) is asked again. The stamp is written only once this reload really happens: when TanStack's render-time reload wins the race, the next document can still heal itself.Evidence
A real one-time 404 on a Reels chunk, served by the app with no Playwright routing, then the file put back:
phone-journey.mobile.spec.ts› "the Reels feed recovers from a module that failed to load once" (one 503 on a Reels module, then the feed must take focus and the tab bar lead home) fails 3/3 onmobile-safari:expect(locator).toBeFocused() failed, element not found.After: passes 5/5 on
mobile-safariand 5/5 onmobile-chrome.stale-chunk-reload.test.ts› "should ask the page modules again before it reloads" fails.After: 6/6 pass.
pnpm checkgreen, the whole e2e suite 307/307 locally,bundle-sizepasses with no budget raised: the recovery adds 0.3 kB of startup JS to every route, since it ships with the entry.Merge Danger
Door: two-way
Blast Radius: recovery-only
The new code runs only after a chunk failed to import, on every page. A wrong module list costs a few requests the HTTP cache mostly answers, and the once-a-minute guard still prevents a reload loop.