Repository navigation
fix(sandbox): make the daemon's decofile-block validation read async - #5481
Merged
Merged
Conversation
publish() blocked the event loop with a synchronous readFileSync while validating each changed decofile block, on the same single-threaded Bun loop that answers the daemon's /health probe (CONTRIBUTING rule #1). Continues the same conversion already done for the daemon's other routes (discard, glob, URL-transfer).
pedrofrxncx
added a commit
that referenced
this pull request
Jul 31, 2026
publish() called mkdtempSync while running on the daemon's single-threaded Bun event loop, blocking it for the duration of the syscall — the same class of bug already fixed for the discard route (#5471) and decofile-block validation (#5481). Continue that conversion here: mkdtemp (fs/promises), awaited from the already-async publish() path.
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.
Continues the daemon's ongoing sync-fs-to-async hardening (#5333, #5336, #5367, #5370, #5372, #5375, #5413, #5442, #5471) — CONTRIBUTING.md rule #1: no blocking sync fs work on the sandbox daemon's single-threaded Bun event loop, since a stall there misses the /health probe and Studio tears the pod down.
publish()(packages/sandbox/daemon/routes/git.ts) is invoked both from the interactivePOST /_sandbox/git/publishroute and from the daemon's shutdown handler, and it loops over every changed decofile block reading its content withfs.readFileSyncto validate the JSON before allowing a commit. That call was fully synchronous and blocked the event loop for the duration of the read on every publish.Fix: swapped
fs.readFileSyncforreadFilefromnode:fs/promises, madepublish()async, and awaited its two call sites (the publish route handler in git.ts, and the shutdown-sync call in entry.ts).Behavior is unchanged — same validation logic, same return value/thrown errors, just non-blocking. All 10 test cases that call
publish()directly (routes/git.test.ts) were updated toasync/await(sync-throw assertions becameawait expect(...).rejects.toThrow(...)); no assertions changed.Reviewer check:
cd packages/sandbox && bunx tsc --noEmit, thenbun test packages/sandbox/daemon/routes/git.test.ts(51 pass).Locally verified:
bun run fmt,bunx tsc --noEmitin packages/sandbox (clean), and the single targeted test file (51/51 pass). Full CI covers the e2e git-route suite.Summary by cubic
Switched decofile-block validation to async file reads in the sandbox daemon to avoid blocking
publish(). Keeps/healthresponsive and prevents pod teardown; behavior is unchanged.fs.readFileSyncwithreadFilefromnode:fs/promisesinpublish().publish()async and awaited inpackages/sandbox/daemon/routes/git.tsandpackages/sandbox/daemon/entry.ts.async/awaitwithrejects.toThrow(...); assertions unchanged.Written for commit 217dfe9. Summary will update on new commits.