Repository navigation
fix(sandbox): make the daemon edit route async - #5391
Merged
Merged
Conversation
decocms Bot
pushed a commit
that referenced
this pull request
Jul 29, 2026
PR: #5391 fix(sandbox): make the daemon edit route async Bump type: patch - @decocms/sandbox (packages/sandbox/package.json): 1.26.0 -> 1.26.1 - deploy/helm/sandbox-env (chart 0.9.43) (deploy/helm/sandbox-env/values.yaml deploy/helm/sandbox-env/Chart.yaml): image.tag/appVersion -> 1.26.1 Deploy-Scope: both
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 #5370/#5372/#5375, which converted the daemon's write/unlink/mkdir routes from sync to async fs calls. The
editroute (makeEditHandlerinpackages/sandbox/daemon/routes/fs.ts) still usedfs.readFileSync/fs.writeFileSync, so a large file edit blocks the daemon's single-threaded event loop, which can cause a missed health probe and trigger sandbox teardown/recovery (see CONTRIBUTING.md rule #1).This PR swaps those two calls for the already-imported
readFile/writeFilefromnode:fs/promises, withawait. Behavior is unchanged (same error handling, same return shape) — only the read/write path stops blocking the loop.Other sync fs calls remain in this file (
read,rename,glob,upload_to_urlhandlers) and are left for follow-up PRs, matching the established one-route-per-PR pattern.Reviewer check:
bun test packages/sandbox/daemon/routes/fs.test.ts(56 pass, 0 fail).Locally verified:
cd packages/sandbox && bunx tsc --noEmit(clean), targeted test file above (all green),bun run fmt(no changes needed). Full CI validates the rest.Summary by cubic
Make the sandbox daemon
editroute async to avoid blocking the event loop on large file edits, preventing missed health probes and sandbox teardown. Replaces syncfs.readFileSync/fs.writeFileSyncwithreadFile/writeFilefromnode:fs/promises, with no behavior changes.Written for commit 83aa7bc. Summary will update on new commits.