Skip to content

fix(web): retry boot chunk failures up to 3 times per minute (CLO-1310) - #241

Open
nullStack65 wants to merge 2 commits into
release/native-0.1.10from
fix/clo-1310-boot-reload-guard
Open

nullStack65 wants to merge 2 commits into
release/native-0.1.10from
fix/clo-1310-boot-reload-guard

Conversation

@nullStack65

Copy link
Copy Markdown
Owner

Problem

The web app dead-ended on "T3 Code failed to start" when the network flapped during boot (the boot recovery issue, CLO-1310). chunkReloadGuard reloaded the page once per build per tab, ever. If that reload hit the same blip, the user was stuck on the boot error screen, and a later transient failure in the same tab got no retry either. The CLO-1299 sweep measured this at 2 of 100 cold loads on a busy host, and 7 of 248 page loads in the full sweep.

Change

  • apps/web/src/lib/chunkReloadGuard.ts: up to 3 automatic reloads per 60 s window, with growing delays (0.75 s, 1.5 s, 2.25 s), counted per build in sessionStorage. A chunk that is really gone still stops after 3 attempts, and after the window passes a later blip gets a fresh set. Further vite:preloadError events in a document that already scheduled a reload share that reload instead of spending attempts. The old plain-string marker is read as a fresh window.
  • Tests: chunkReloadGuard.test.ts covers the cap, the delays, window expiry, counting across reloads inside the window, a build change, the legacy marker and blocked storage. bootstrap.test.ts adds "reloads again when the first automatic reload hit the same blip" and "shows the boot error once every automatic reload failed".

Evidence (head 345ac90, base release/native-0.1.10 @ 9fd13fa, Node 26.13.1)

  • vp test run --project unit src/lib/chunkReloadGuard.test.ts src/bootstrap.test.ts src/bundledDev.test.ts: 3 files, 14 tests passed.
  • Negative check: against the old guard, the new bootstrap test reloads again when the first automatic reload hit the same network blip fails, so it catches the dead end.
  • vp lint on the changed files is clean, and vp fmt --check passes. vp test run scripts/feature-map.test.ts passes (4 tests).
  • effect-tsgo tsrs --noEmit in apps/web: none of the errors are in the changed files. The 9 existing errors in Sidebar.logic.test.ts and botOrgTree.test.ts are present on the base.

Not verified here: the browser repro (qa/specs/70-reliability.spec.ts from the sweep harness) is not in this repo, so I did not re-run it against this build.

Prior art

  • Vite's documented vite:preloadError + window.location.reload() pattern: already in use. This change only bounds it per window instead of once.
  • Workbox or a service worker cache for the chunks: too heavy for this problem, and it adds stale-asset risk. Rejected.
  • Searched: Vite "Load Error Handling" docs for vite:preloadError (Nov 2026).

Model: claude-opus-5-5
Task: fix

Deploy: fleet

🤖 Generated with Claude Code

The chunk reload guard allowed one automatic reload per build per tab,
forever. When a network blip failed the entry chunk and the reload hit
the same blip, the tab dead-ended on "T3 Code failed to start", and any
later transient failure in that tab got no retry at all.

Allow up to 3 automatic reloads in a 60 second window, with growing
delays (0.75 s, 1.5 s, 2.25 s), counted per build in sessionStorage. A
chunk that is really gone still stops after 3 attempts; a blip after the
window has passed gets a fresh set. Further preload errors in a document
that already scheduled a reload share it instead of spending attempts.

Model: claude-opus-5-5
Task: fix
Agent: Builder
Lane: magpie
Harness: t3/claude-code
Model-family: Claude Opus (runtime model label)
Model-generation: 5.5 (runtime model label)
Skills-SHA: unknown (no Skills consulted)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@nullStack65

Copy link
Copy Markdown
Owner Author

Auto-rebase escalated (not pushed). Head checked: 345ac90.

Rebasing onto the current release/native-0.1.10 conflicts in three files: apps/web/src/lib/chunkReloadGuard.ts, apps/web/src/lib/chunkReloadGuard.test.ts and apps/web/src/bootstrap.test.ts.

This is a semantic conflict, not a textual one. The base already contains the pull request that merged as 53ae52a ("reload up to three times on a failed chunk instead of dead-ending"). It implements the same behavior with a different design:

  • Window: 10 minutes on the base, 60 seconds in this PR (RELOAD_WINDOW_MS).
  • Signature: positional arguments (getStorage, reload, build, now) on the base, an options object { getStorage, reload, build, now, schedule } in this PR.
  • Constant names: MAX_RELOADS on the base, MAX_RELOADS_PER_WINDOW in this PR.
  • The base's bootstrap.test.ts uses fake timers and a build/stamps record. This PR stubs window.setTimeout.

A human or System-2 should decide whether this PR is now redundant (close it) or whether only the 60-second window should be kept on top of the base's implementation (a small follow-up change).

@nullStack65

Copy link
Copy Markdown
Owner Author

Auto-rebase escalated (not pushed). Head stayed 345ac90.

The rebase onto release/native-0.1.10 (8ff44f5) conflicts in three files, and the conflict is semantic, not textual:

  • apps/web/src/lib/chunkReloadGuard.ts
  • apps/web/src/lib/chunkReloadGuard.test.ts
  • apps/web/src/bootstrap.test.ts

The base branch already contains "reload up to three times on a failed chunk" (the earlier web fix, merged as #240). It implements the same behavior as this PR with a different design: a list of reload timestamps in a 10-minute window, with reloadForChunkLoadError(getStorage, reload(delayMs), build, now) positional args. This PR uses a count plus windowStart in a 60-second window, with an options-object signature and exported constants.

Decision needed (System-2 or a human): drop this PR as superseded, or reduce it to only the delta wanted (for example the 60 s window or the options-object API) rebuilt on top of the base implementation. A mechanical conflict resolution would pick one design silently.

The base already carries the CLO-1310 chunk reload retry from the merged
"reload up to three times on a failed chunk" change, so the conflicts
resolve to the base version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nullStack65

Copy link
Copy Markdown
Owner Author

Conflict repair: merged release/native-0.1.10 into this branch (head a8e704513d).

The base already carries the same fix for the same ticket (CLO-1310, boot chunk failures dead-ending): the merged change "reload up to three times on a failed chunk instead of dead-ending" (#240). It caps reloads at three per build in a 10 minute sliding window, spaced 0.75 s and growing. This PR's version did the same thing with a fixed 60 s window. All three conflicting files (chunkReloadGuard.ts, its test, and bootstrap.test.ts) were resolved to the base version, so this PR now has no diff against the base branch.

Tests: vp test run --project unit src/lib/chunkReloadGuard.test.ts src/bootstrap.test.ts src/main.test.ts in apps/web passed (3 files, 15 tests).

Recommendation: close this PR as superseded instead of merging an empty change.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant