Skip to content

refactor(sandbox): make the daemon glob route's directory walk async - #5442

Merged
pedrofrxncx merged 1 commit into
mainfrom
refactor/glob-walk-async-w1
Jul 30, 2026
Merged

pedrofrxncx merged 1 commit into
mainfrom
refactor/glob-walk-async-w1

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 30, 2026 •

Copy link
Copy Markdown
Collaborator

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's maxDepth walk (walkRepoWithinMaxDepth) used fs.readdirSync, and the plain Bun.Glob branch used fs.statSync on every matched entry — both run synchronously inside the request handler. This PR swaps both for the already-imported readdir/stat promises from node: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 — covers makeGlobHandler including the maxDepth walk path).

Locally verified: bun run fmt, bunx tsc --noEmit in packages/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.

  • Refactors
    • Replaced fs.readdirSync with readdir from node:fs/promises and made walkRepoWithinMaxDepth async.
    • Replaced fs.statSync with stat in the Bun.Glob branch.

Written for commit 00ef7bc. Summary will update on new commits.

Review in cubic

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).
@pedrofrxncx
pedrofrxncx merged commit a36d60f into main Jul 30, 2026
23 checks passed
@pedrofrxncx
pedrofrxncx deleted the refactor/glob-walk-async-w1 branch July 30, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant