Repository navigation
refactor(sandbox): make the daemon glob route's directory walk async - #5442
Merged
Merged
Conversation
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/#5406/#5336/#5367 (CONTRIBUTING.md rule #1: no sync fs in the sandbox daemon's single-threaded event loop — it blocks the health probe Studio polls, and a missed probe tears the sandbox down/triggers recovery).
makeGlobHandler'smaxDepthwalk (walkRepoWithinMaxDepth) usedfs.readdirSync, and the plainBun.Globbranch usedfs.statSyncon every matched entry — both run synchronously inside the request handler. This PR swaps both for the already-importedreaddir/statpromises fromnode:fs/promises, no behavior change (same recursion, same return values, just awaited).Net: -9/+9, pure sync→async swap, no logic change.
Reviewer command:
cd packages/sandbox && bun test daemon/routes/fs.test.ts(56 pass, 9 skip, 0 fail — coversmakeGlobHandlerincluding themaxDepthwalk path).Locally verified:
bun run fmt,bunx tsc --noEmitinpackages/sandbox(clean), and the targeted test file above. Full CI covers the rest.Summary by cubic
Make the sandbox daemon’s glob route async to avoid blocking the event loop and health probes. Swaps sync FS calls for async equivalents with no behavior change.
fs.readdirSyncwithreaddirfromnode:fs/promisesand madewalkRepoWithinMaxDepthasync.fs.statSyncwithstatin theBun.Globbranch.Written for commit 00ef7bc. Summary will update on new commits.