Repository navigation
fix(sandbox): make the daemon rename route async - #5406
Merged
Merged
Conversation
pedrofrxncx
enabled auto-merge (squash)
July 30, 2026 05:49
pedrofrxncx
added a commit
that referenced
this pull request
Jul 30, 2026
write_from_url and upload_to_url ran fs.mkdirSync/rmSync/statSync directly in the request handler, blocking the daemon's single-threaded event loop on every call (mkdirSync/statSync on every request, rmSync on failure). This mirrors the read/rename route fixes (#5403, #5406) using the already-imported mkdir/rm/stat promises.
pedrofrxncx
added a commit
that referenced
this pull request
Jul 30, 2026
…5442) walkRepoWithinMaxDepth used fs.readdirSync, and makeGlobHandler's Bun.Glob branch used fs.statSync, both blocking the daemon's single-threaded event loop on every glob call. Swap in the already-imported readdir/stat promises, mirroring the read/rename/ unlink/mkdir/write route fixes (#5403, #5406, #5336, #5367).
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 #5403 (async read route) — continues converting the sandbox daemon's fs routes off blocking sync I/O, one route per PR (see also #5333, #5336).
The daemon runs on a single-threaded Bun event loop and Studio tears down/recovers a sandbox on a single missed health probe.
makeRenameHandlerinpackages/sandbox/daemon/routes/fs.tscalledfs.statSync(twice),fs.mkdirSync, andfs.renameSync— each one blocks the loop for the duration of the syscall, so a rename on a large/slow filesystem (or heavy concurrent traffic) could starve the health probe and get the sandbox killed.Swapped all four for their
node:fs/promisesequivalents (stat,mkdir,rename) already imported/used elsewhere in this file. Purely mechanical, behavior-preserving — same checks, same error responses, same order of operations.Reviewer check:
bun test packages/sandbox/daemon/routes/fs.test.ts(existingrename:cases cover the moved-file and destination-already-exists paths).Locally ran:
bun run fmt,cd packages/sandbox && bunx tsc --noEmit, and the targeted test file above — all green. Full CI covers the rest.Summary by cubic
Make the sandbox daemon’s rename route async to avoid blocking the single-threaded event loop. This reduces the chance of health probe timeouts on slow filesystems and improves sandbox stability.
fs.statSync,fs.mkdirSync, andfs.renameSyncwithstat,mkdir, andrenamefromnode:fs/promises.Written for commit 92ca568. Summary will update on new commits.