[Bug]: File preview panel highlights large files synchronously on the renderer main thread #8356
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/web
Steps to reproduce#
- In a thread, open a large source file in the file preview panel (repro: a 476 KB, 10,915-line Go file).
- Navigate away, then reopen the thread so the pane restores and re-highlights the file.
- The window freezes: thread switching, closing the pane, and most clicks stop responding.
Expected behavior#
The UI stays interactive regardless of file size — large files highlight off the main thread (the diff path already has DiffWorkerPoolProvider), or fall back to plain text above a size threshold.
Actual behavior#
The renderer main thread pegs at ~200% CPU in one synchronous JS call and never recovers: one instrumented reproduction held ~200% continuously for 12+ minutes (10-second CPU log, same pid throughout) until the app was force-quit. Two sample captures taken 16 s apart during an earlier reproduction show the identical call stack down to the JIT return addresses — a single tokenization pass holding the main thread — with the hot leaf in v8::String::NewFromOneByte under ~40 JIT-compiled frames.
Cause: apps/web/src/components/files/FilePreviewPanel.tsx renders files through @pierre/diffs Editor/File with preferredHighlighter: "shiki-js" (apps/web/src/lib/syntaxHighlighting.ts). Unlike the diff path it does not use the worker pool, and there is no file-size cap, so the whole file is tokenized synchronously on the renderer main thread on every restore.
Impact#
Blocks work completely
Version or commit#
0.0.34-nightly.20260825.1183
Environment#
macOS (Darwin 25.4.0, Apple Silicon), Electron 41.5.0, Claude provider
Logs or stack traces#
Both samples (5 s each, 16 s apart), main thread, 100% of samples in one chain:
ElectronMain (Electron Framework)
→ v8::Function::NewInstanceWithSideEffectType
→ ~40 frames of JIT-compiled JS (<unknown binary>)
→ v8::String::NewFromOneByte ← hot leaf, hundreds of distinct JIT call sites
CPU log during reproduction (10 s interval, excerpt):
21:10:00 renderer 51445: 7.0% ← thread opened here
21:10:10 renderer 51445: 201.4%
... every sample 197–201% ...
21:22:15 renderer 51445: 199.8% ← 12+ min later, same pid, still pegged
Workaround#
None found beyond force-quitting the app and avoiding the thread whose pane restores the large file. Waiting does not recover it (12+ minutes observed).
Related#
- #3884 (same highlighting library, worker-side CPU spin on Linux)
- #4596 (similar symptom on thread reopen, different mechanism)
Built with Claude Fable 5 in Claude Code.
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.