Repository navigation
fix(sandbox): make the daemon read route async - #5403
Merged
Merged
Conversation
The /read route's file stat, open/read/close, and readFile calls used the sync fs API, blocking the daemon's single-threaded event loop for the duration of every file read (including large text/image reads) and risking a missed health probe under load. Switch to node:fs/promises equivalents. Follows the same conversion already applied to mkdir/unlink/edit routes (#5372, #5375, #5391).
decocms Bot
pushed a commit
that referenced
this pull request
Jul 30, 2026
PR: #5403 fix(sandbox): make the daemon read route async Bump type: patch - @decocms/sandbox (packages/sandbox/package.json): 1.28.1 -> 1.28.2 - deploy/helm/sandbox-env (chart 0.9.49) (deploy/helm/sandbox-env/values.yaml deploy/helm/sandbox-env/Chart.yaml): image.tag/appVersion -> 1.28.2 Deploy-Scope: both
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.
Continues the sync-fs-to-async cleanup in the sandbox daemon (CONTRIBUTING.md rule #1) started by #5372 (unlink), #5375 (mkdir), and #5391 (edit) — the daemon runs on a single-threaded Bun event loop and Studio tears down a sandbox on a single missed health probe.
Why a maintainer wants it:
makeReadHandler(the/readroute, the daemon's most-hit file-content endpoint) still usedfs.statSync/fs.openSync/fs.readSync/fs.closeSync/fs.readFileSync— every file read (including full-file text reads and up-to-5MB image reads) blocked the event loop for the read's duration, which could stall the health probe under concurrent load.Change: swap those for
node:fs/promisesequivalents (stat,open+FileHandle.read+close,readFile), matching the pattern already used by the sibling write/edit handlers in the same file. Pure mechanical async conversion — no behavior change (same error paths, same probe-then-decide-image-vs-text logic).Verify:
cd packages/sandbox && bunx tsc --noEmitandbun test packages/sandbox/daemon/routes/fs.test.ts(56 pass, 9 skip, 0 fail — pre-existing suite, no assertions changed).Locally ran:
bun run fmt, targetedtsc --noEmitinpackages/sandbox, and the singlefs.test.tsfile. Full CI covers the rest.Summary by cubic
Convert the sandbox daemon
/readroute to async I/O so it no longer blocks the event loop. This prevents stalls on large text/image reads and makes health probes more reliable.fs.statSync/openSync/readSync/closeSync/readFileSyncwithstat,open+FileHandle.read+close, andreadFilefromnode:fs/promises.Written for commit 2d30aa9. Summary will update on new commits.