Repository navigation
Description
I have three small fixes for the TypeScript server ready. The repo only accepts PRs from collaborators, so they are single commits on dev (6ae06c2) in my fork and can be cherry-picked as is. Each includes a regression test that fails on dev and passes with the fix; CI on the fork is green for all three.
1. The merge pump hangs on a destroyed stream
Branch: chenrui333:fix/merge-pump-destroyed-sink (diff, review copy)
The first download of an unmerged entry tees its parts into the client response and the background merge upload. pumpPartsToStreams only waits for 'drain', but a destroyed stream returns false from write() and never emits 'drain' (nor 'error' when destroyed without one). So the pump parks forever when:
- the merge upload fails:
download()destroys the merger stream without an error, and the client's download stalls mid-body; - the client leaves while the pump is waiting on the merger: the next write to the destroyed response parks the pump, the merge never completes and its lease keeps renewing.
Each hung pump keeps its part's storage read open (one S3 socket each), so enough of them fill the S3 agent's 50 sockets and every other request queues behind them. The fix waits for 'drain' or 'close', skips destroyed sinks, keeps feeding the one still open, and stops reading once both are gone. tests/download-merge-sink-gone.test.ts covers the three cases; all fail on dev with the filesystem and S3 drivers.
#288 already handles this (keeps_merging_after_the_client_goes_away).
2. A forced full GC after every part throttles first restores
Branch: chenrui333:perf/no-forced-gc (diff, review copy)
streamParts() awaits globalThis.gc() after every part and the image runs node --expose-gc, so every part of every unmerged restore and streaming merge runs a synchronous full mark-compact on the event loop. With ~1 MiB BuildKit parts, all concurrent first restores together are capped at about one part per GC pause. Since #275 and #282 the bytes in flight are bounded by backpressure, so the calls no longer buy anything. The branch removes both calls, --expose-gc and the startup warning.
Concurrent first restores of unmerged 96 × 1 MiB entries, SQLite + filesystem, one worker, SHA-256 checked:
| Concurrent restores | dev (--expose-gc) |
without forced GC |
|---|---|---|
| 16 | 14.4–15.3 s (100–107 MiB/s), peak RSS 278–311 MiB | 1.4–2.6 s (588–1079 MiB/s), peak RSS 343–352 MiB |
| 32 | 31.7–40.5 s (76–97 MiB/s), peak RSS 238–339 MiB | 9.7–12.1 s (255–316 MiB/s), peak RSS 342–351 MiB |
Peak RSS stays around 350 MiB at both 16 and 32 restores, so memory remains bounded without the forced collections. Warm (merged) restores are unaffected.
3. DELETE /management-api/cache-entries ignores repoId
Branch: chenrui333:fix/management-delete-repo-id (diff, review copy)
The handler accepts and documents repoId but never applies it, so a delete filtered only by repository removes every entry. One line plus tests/management-api.test.ts. #288 already fixes this in Rust; this is the same fix for the current server.
I also have the S3 socket-pool and merge-concurrency changes I have been running on a patched 9.8.0 (separate read/write/control S3 agents, a merge cap, an idle timeout for stalled downloads). I'll open a separate issue for those once they are rebased onto dev with tests.
Activity
chenrui333 commentedon Oct 24, 2026
@LouisHaftmann the patches for this issue and for #293 and #294 are ready as pull requests, but the repo only accepts PRs from collaborators (
pull_request_creation_policy: collaborators_only), so I can't open them here. Which do you prefer?dev(6ae06c2), except two stacked ones, which are noted in S3 pool deadlock, unbounded merges and stalled downloads: fixes from a patched 9.8.0 #293 and Auth and logging hardening: token safeguards, query strings in logs, signed upload URLs #294. Example:git fetch https://github.com/chenrui333/github-actions-cache-server fix/merge-pump-destroyed-sink && git cherry-pick FETCH_HEAD.dev.Each branch has fork CI and a Codex review on the linked review copy. I'll rebase them if
devmoves.