Task
dig-node's serve integration test creates a temp directory per run and never removes it. It
accumulated 1,123 directories totalling 62.5 GB in %LOCALAPPDATA%\Temp, which took the dev machine
to 81 MB free on a 1.9 TB disk and produced a machine-wide ENOSPC that stopped an unrelated lane
mid-build.
Make the test clean up after itself.
Measured
1,123 dirs dig-node-serve-test-<pid>-<n> 62.47 GB (~57 MB each)
Deleting them recovered the disk from 81 MB → 66.5 GB free.
The same Temp tree holds ~38,000 further leaked dirs from sibling tests, near-zero bytes each but real
filesystem clutter:
| dirs |
bytes |
prefix |
| 9,898 |
~0 |
dig-tip* |
| 6,832 |
~0 |
dig-node-auth* |
| 6,701 |
0.77 GB |
dig-node-test* |
| 5,683 |
~0 |
dig-node-custody* |
| 3,659 |
0.01 GB |
dig-wallet-sup* |
| 2,585 |
~0 |
dig-wallet-rpc-authgate* |
| 1,354 |
0.07 GB |
dig-wallet-svc* |
dig-node-serve-test is the only one that matters for space; the rest matter because 50,000 entries
make every Temp scan slow and make the real leak hard to see. Fixing the shared helper likely fixes all
of them at once.
Why this is a defect and not housekeeping
It took down a machine. ENOSPC is a CLAUDE.md hard STOP (§1.6, §1.7): the lane that hit it correctly
refused to free space by deleting a sibling lane's target/, so it had to stop and hand back. Every Rust
lane on the machine was blocked until an orchestrator intervened.
It is also self-concealing: the leak grows fastest exactly when the test suite runs most, so it
surfaces during heavy development and looks like a build-cache problem. The first diagnosis here blamed
worktree target/ dirs — which totalled ~25 GB across six worktrees and were not the cause.
Likely shape of the fix
Use an RAII temp-dir guard (e.g. tempfile::TempDir) rather than a constructed path, so cleanup happens
on drop including on panic. Note the related trap already recorded in this repo: a cleanup placed
after an .await leaks on panic if anything catches it — the guard must own the directory, not a
deferred cleanup step.
If a test deliberately preserves its dir on failure for diagnosis, that is legitimate — but it must then
be bounded (keep the last N, or delete on success) rather than unbounded.
Done condition
Run the serve integration suite twice and show the Temp dig-node-serve-test* count returns to its
pre-run value. A test that asserts its own cleanup is better than a manual check.
Scope
The temp-dir lifecycle in the test helpers. Do not widen into the tests' actual assertions.
Effort
Low-to-medium — one shared helper, but verify it covers the panic path, which is where this class
normally survives a fix.
Task
dig-node's serve integration test creates a temp directory per run and never removes it. Itaccumulated 1,123 directories totalling 62.5 GB in
%LOCALAPPDATA%\Temp, which took the dev machineto 81 MB free on a 1.9 TB disk and produced a machine-wide
ENOSPCthat stopped an unrelated lanemid-build.
Make the test clean up after itself.
Measured
Deleting them recovered the disk from 81 MB → 66.5 GB free.
The same
Temptree holds ~38,000 further leaked dirs from sibling tests, near-zero bytes each but realfilesystem clutter:
dig-tip*dig-node-auth*dig-node-test*dig-node-custody*dig-wallet-sup*dig-wallet-rpc-authgate*dig-wallet-svc*dig-node-serve-testis the only one that matters for space; the rest matter because 50,000 entriesmake every
Tempscan slow and make the real leak hard to see. Fixing the shared helper likely fixes allof them at once.
Why this is a defect and not housekeeping
It took down a machine. ENOSPC is a CLAUDE.md hard STOP (§1.6, §1.7): the lane that hit it correctly
refused to free space by deleting a sibling lane's
target/, so it had to stop and hand back. Every Rustlane on the machine was blocked until an orchestrator intervened.
It is also self-concealing: the leak grows fastest exactly when the test suite runs most, so it
surfaces during heavy development and looks like a build-cache problem. The first diagnosis here blamed
worktree
target/dirs — which totalled ~25 GB across six worktrees and were not the cause.Likely shape of the fix
Use an RAII temp-dir guard (e.g.
tempfile::TempDir) rather than a constructed path, so cleanup happenson drop including on panic. Note the related trap already recorded in this repo: a cleanup placed
after an
.awaitleaks on panic if anything catches it — the guard must own the directory, not adeferred cleanup step.
If a test deliberately preserves its dir on failure for diagnosis, that is legitimate — but it must then
be bounded (keep the last N, or delete on success) rather than unbounded.
Done condition
Run the serve integration suite twice and show the
Tempdig-node-serve-test*count returns to itspre-run value. A test that asserts its own cleanup is better than a manual check.
Scope
The temp-dir lifecycle in the test helpers. Do not widen into the tests' actual assertions.
Effort
Low-to-medium — one shared helper, but verify it covers the panic path, which is where this class
normally survives a fix.