Repository navigation
fix(sandbox): make golden-cache node-local disk I/O async - #5478
Merged
Merged
Conversation
golden-cache.ts used readFileSync/statSync/mkdirSync/readdirSync/rmSync/ renameSync/utimesSync throughout. tryRestoreGolden, publishGolden, and pruneGoldens all run from fire-and-forget calls (entry.ts's `void orchestrator.publishPendingGolden()`, itself invoked off the `running` health transition) while the daemon's Bun.serve is already answering requests, so every sync fs call there parks the single-threaded event loop and can miss the daemon's own health probe (CONTRIBUTING.md rule #1) — pruneGoldens is the worst offender, since it walks and stats every golden dir on the node. Converts every call to node:fs/promises equivalents, matching the async style remote-golden.ts (L2) already uses. resolveRemote in remote-golden.ts awaits the now-async lockfileHash it imports from golden-cache.ts. Behavior-preserving: same logic, same fallbacks, same log lines.
pedrofrxncx
enabled auto-merge (squash)
July 31, 2026 01:59
decocms Bot
pushed a commit
that referenced
this pull request
Jul 31, 2026
PR: #5478 fix(sandbox): make golden-cache node-local disk I/O async Bump type: patch - @decocms/sandbox (packages/sandbox/package.json): 1.28.5 -> 1.28.6 - deploy/helm/sandbox-env (chart 0.9.53) (deploy/helm/sandbox-env/values.yaml deploy/helm/sandbox-env/Chart.yaml): image.tag/appVersion -> 1.28.6 Deploy-Scope: both
This was referenced Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows the daemon's async-fs hardening lane (#5333, #5336, #5367, #5370, #5372, #5375) — this is the golden-cache.ts instance of the same bug class.
golden-cache.tsusedreadFileSync/statSync/mkdirSync/readdirSync/rmSync/renameSync/utimesSyncthroughout.tryRestoreGolden,publishGolden, andpruneGoldensall run from a fire-and-forget call (entry.ts'svoid orchestrator.publishPendingGolden(), fired off therunninghealth transition) while the daemon'sBun.serveis already answering requests — so every sync fs call there parks the single-threaded event loop and can make the daemon miss its own health probe (CONTRIBUTING.md rule #1: a single miss gets the pod marked dead and torn down).pruneGoldensis the worst offender: it walks andstats every golden directory on the node.Why a maintainer wants this: it closes a real, provable liveness gap on the sandbox boot path — one that has already been the subject of ~6 merged PRs elsewhere in this same daemon (routes/fs.ts, discard route, etc.) but was still open here in setup/golden-cache.ts.
Change: converts every blocking call to its
node:fs/promisesequivalent, matching the async styleremote-golden.ts(the L2 tier) already uses.resolveRemoteinremote-golden.tsnow awaits the (now-async)lockfileHashit imports fromgolden-cache.ts.orchestrator.ts's onepruneGoldens()call site is now awaited. Behavior-preserving: identical logic, fallbacks, and log lines — only the I/O calls changed from sync to async equivalents.Command a reviewer can run:
bun test packages/sandbox/daemon/setup/golden-cache.test.ts packages/sandbox/daemon/setup/remote-golden.test.tsLocally verified:
bun run fmt,bunx tsc --noEmitinpackages/sandbox(clean), and the two targeted test files above (19 + 7 pass). Also ranpackages/sandbox/daemon/setup/orchestrator.test.ts— one pre-existing failure (corepackbinary missing in this sandbox) reproduces identically on main before this change, so it's unrelated. Full CI validates the rest.Summary by cubic
Make golden-cache disk I/O async to avoid event-loop blocking during sandbox boot and prevent health probe misses. Replaced sync fs calls with
node:fs/promisesacross restore, publish, and prune paths without changing behavior.node:fs/promises).lockfileHash,sameFilesystem, and internal resolvers async; updated callers.orchestratornow awaitspruneGoldens();remote-goldenawaitslockfileHashinresolveRemote.Written for commit 02a96aa. Summary will update on new commits.