Skip to content

Commit ba6d45d

Browse files
committed
docs(dev): document cache-corruption recovery, the cost of enabling the cache
Stress-tested the failure mode rather than assuming it: deliberately corrupting an SST block makes Turbopack abort with a FATAL panic — it does not self-heal. FATAL: An unexpected Turbopack error occurred. Cache corruption detected: checksum mismatch in block 4 of 00000221.sst `bun run dev:cache:prune` and restart fixes it; verified the canvas serves 200 again afterwards. Documented in the skill and in the script's header, since the symptom is a hard crash and the remedy is not guessable. This is the honest cost of turning the cache on. It is worth paying — a 5.4x faster restart against a rare, loud, single-command failure — but it should be written down rather than discovered. Worth distinguishing from the adjacent case: an ordinary hard kill does *not* corrupt the cache. Turbopack discards a partially-written cache and rebuilds it silently, which is exactly why a `kill -9`-based benchmark reads as "no cache win" (noted in the benchmarking section).
1 parent 6da0496 commit ba6d45d

4 files changed

Lines changed: 57 additions & 1 deletion

File tree

.agents/skills/dev-performance/SKILL.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ The dev cache is unbounded on disk — an abandoned one in this repo reached **7
3939

4040
Chained explicitly rather than via a `predev` lifecycle hook: Turbo does fire `pre*` hooks (verified), but an explicit `&&` is visible in the command, survives any invocation path, and needs no per-variant `predev:*` duplicate.
4141

42+
### If the dev server dies with a Turbopack panic
43+
44+
An on-disk cache can be corrupted (disk full, an OS crash, a bad write). Turbopack does **not** self-heal from that — it detects the checksum mismatch and aborts:
45+
46+
```
47+
FATAL: An unexpected Turbopack error occurred.
48+
Cache corruption detected: checksum mismatch in block 4 of 00000221.sst
49+
```
50+
51+
The fix is one command, then restart:
52+
53+
```bash
54+
bun run dev:cache:prune
55+
```
56+
57+
This is the known cost of the cache being on, and it is worth it: the cache buys a 5.4x faster restart, and the failure is loud and single-command rather than silent or subtle. Note that an ordinary hard kill does **not** corrupt the cache — Turbopack discards a partially-written cache and rebuilds it silently (which is why a `kill -9` benchmark reads as "no cache win").
58+
4259
## How to benchmark a dev-performance change
4360

4461
Anything less than this and the number is not trustworthy.

.claude/commands/dev-performance.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@ The dev cache is unbounded on disk — an abandoned one in this repo reached **7
3838

3939
Chained explicitly rather than via a `predev` lifecycle hook: Turbo does fire `pre*` hooks (verified), but an explicit `&&` is visible in the command, survives any invocation path, and needs no per-variant `predev:*` duplicate.
4040

41+
### If the dev server dies with a Turbopack panic
42+
43+
An on-disk cache can be corrupted (disk full, an OS crash, a bad write). Turbopack does **not** self-heal from that — it detects the checksum mismatch and aborts:
44+
45+
```
46+
FATAL: An unexpected Turbopack error occurred.
47+
Cache corruption detected: checksum mismatch in block 4 of 00000221.sst
48+
```
49+
50+
The fix is one command, then restart:
51+
52+
```bash
53+
bun run dev:cache:prune
54+
```
55+
56+
This is the known cost of the cache being on, and it is worth it: the cache buys a 5.4x faster restart, and the failure is loud and single-command rather than silent or subtle. Note that an ordinary hard kill does **not** corrupt the cache — Turbopack discards a partially-written cache and rebuilds it silently (which is why a `kill -9` benchmark reads as "no cache win").
57+
4158
## How to benchmark a dev-performance change
4259

4360
Anything less than this and the number is not trustworthy.

.cursor/commands/dev-performance.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,23 @@ The dev cache is unbounded on disk — an abandoned one in this repo reached **7
3434

3535
Chained explicitly rather than via a `predev` lifecycle hook: Turbo does fire `pre*` hooks (verified), but an explicit `&&` is visible in the command, survives any invocation path, and needs no per-variant `predev:*` duplicate.
3636

37+
### If the dev server dies with a Turbopack panic
38+
39+
An on-disk cache can be corrupted (disk full, an OS crash, a bad write). Turbopack does **not** self-heal from that — it detects the checksum mismatch and aborts:
40+
41+
```
42+
FATAL: An unexpected Turbopack error occurred.
43+
Cache corruption detected: checksum mismatch in block 4 of 00000221.sst
44+
```
45+
46+
The fix is one command, then restart:
47+
48+
```bash
49+
bun run dev:cache:prune
50+
```
51+
52+
This is the known cost of the cache being on, and it is worth it: the cache buys a 5.4x faster restart, and the failure is loud and single-command rather than silent or subtle. Note that an ordinary hard kill does **not** corrupt the cache — Turbopack discards a partially-written cache and rebuilds it silently (which is why a `kill -9` benchmark reads as "no cache win").
53+
3754
## How to benchmark a dev-performance change
3855

3956
Anything less than this and the number is not trustworthy.

scripts/prune-turbopack-cache.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
* the win it exists to provide. This script drops the whole cache once it crosses a
1313
* threshold; Turbopack rebuilds it on the next run (one cold compile, ~32s).
1414
*
15-
* Runs automatically on `predev`. Also invokable directly:
15+
* Also the remedy when Turbopack aborts with `Cache corruption detected:
16+
* checksum mismatch` — it does not self-heal from a corrupted cache, so prune
17+
* and restart. (An ordinary hard kill does not corrupt it; Turbopack discards a
18+
* partial write and rebuilds silently.)
19+
*
20+
* Runs automatically before every `dev` script. Also invokable directly:
1621
* bun run scripts/prune-turbopack-cache.ts # prune if over the cap
1722
* bun run scripts/prune-turbopack-cache.ts --force # always prune
1823
* bun run scripts/prune-turbopack-cache.ts --dry-run # report only

0 commit comments

Comments
 (0)