Repository navigation
fix(sandbox): make the daemon mkdir route async - #5375
Merged
Merged
Conversation
decocms Bot
pushed a commit
that referenced
this pull request
Jul 29, 2026
PR: #5375 fix(sandbox): make the daemon mkdir route async Bump type: patch - @decocms/sandbox (packages/sandbox/package.json): 1.25.4 -> 1.25.5 - deploy/helm/sandbox-env (chart 0.9.41) (deploy/helm/sandbox-env/values.yaml deploy/helm/sandbox-env/Chart.yaml): image.tag/appVersion -> 1.25.5 Deploy-Scope: both
This was referenced Jul 29, 2026
pedrofrxncx
added a commit
that referenced
this pull request
Jul 30, 2026
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).
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 #5372 (unlink daemon route made async) and #5336 — continuing the sweep of blocking sync fs calls in
packages/sandbox/daemon/routes/fs.ts.The daemon runs on a single-threaded Bun event loop (CONTRIBUTING.md rule #1).
makeMkdirHandlercalledfs.mkdirSync, which blocks that loop for the duration of the syscall. Studio polls the daemon's HTTP health probe and tears the sandbox down on a single missed probe, so any sync fs call on this path is a latent sandbox-recovery trigger under load.Change: swap
fs.mkdirSync(dirPath, { recursive: true })for the already-importedawait mkdir(dirPath, { recursive: true })fromnode:fs/promises. No behavior change — same recursive-mkdir semantics, same error handling.To confirm:
bun test packages/sandbox/daemon/routes/fs.test.ts(56 pass, coversmakeMkdirHandler).Locally ran:
bun run fmt,cd packages/sandbox && bunx tsc --noEmit(clean), and the targeted test file above. Full CI validates the rest.Remaining sync calls in the same file (
statSync/readFileSync/renameSync/rmSync/readdirSync/etc. in rename, edit, glob, grep handlers) are left for follow-up PRs, one handler at a time, per the established pattern.Summary by cubic
Make the sandbox daemon
mkdirroute async inpackages/sandbox/daemon/routes/fs.tsto prevent blocking the Bun event loop and avoid health probe misses that can tear down the sandbox. Swappedfs.mkdirSyncforawait mkdirfromnode:fs/promises; behavior is unchanged (recursive mkdir and error handling).Written for commit 42e6b97. Summary will update on new commits.