Web: a chunk that fails after boot reloads the page in an endless loop#29304

opened11d agobyGgrodriguez-fr

What happened

On the web client served by t3 serve (0.1.7-nightly.20261102.4066, Chrome 152 on a managed Windows machine), opening any thread whose assistant messages contain a fenced code block reloads the whole page about every 2 seconds, with no end. Settings → Appearance does the same.

The same threads open fine on a phone and in a fresh Chromium on the server host. Something on that machine blocks one of the highlighter chunks (highlights-*.js or one of its dependencies). I couldn't capture the exact console error: the page reloads before it can be read, and the client traces are lost with it.

To reproduce without that machine: make any chunk loaded after boot fail on every request (for example block /assets/highlights-*.js in DevTools), then open a thread with a code block.

Why it loops

main.tsx reloads once on vite:preloadError through reloadOnceForChunkLoadError(), guarded by t3code:chunk-load-reloaded in sessionStorage. But startup calls clearChunkReloadGuard() after every boot where no chunk failed during startup. The highlighter is loaded lazily after boot, so each cycle is:

  1. boot succeeds, the guard is cleared;
  2. the code block renders and the highlighter chunk fails;
  3. the guard is empty, so the page reloads.

In the server trace, the thread's document was requested 8 times in about 10 s, each time about 1 s after /api/orchestration/threads/:id/bounded returned 200.

Without the reload, the failure would be harmless: the code block's error boundary in ChatMarkdown already falls back to a plain <pre>.

Workaround

Patching the built main-*.js so the guard expires after a few minutes instead of being cleared at boot stops the loop. After a hard refresh, the page reloads at most once and code blocks render without highlighting.

Related: #26437 and #26451 handle a failure of the main chunk during boot. #26451 keeps clearing the guard at boot, so it doesn't cover this case.