Skip to content

fix(sandbox): make the daemon edit route async - #5391

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/edit-route-async-w1
Jul 29, 2026
Merged

pedrofrxncx merged 1 commit into
mainfrom
fix/edit-route-async-w1

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 29, 2026 •

Copy link
Copy Markdown
Collaborator

Follows #5370/#5372/#5375, which converted the daemon's write/unlink/mkdir routes from sync to async fs calls. The edit route (makeEditHandler in packages/sandbox/daemon/routes/fs.ts) still used fs.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/writeFile from node:fs/promises, with await. 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_url handlers) 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 edit route async to avoid blocking the event loop on large file edits, preventing missed health probes and sandbox teardown. Replaces sync fs.readFileSync/fs.writeFileSync with readFile/writeFile from node:fs/promises, with no behavior changes.

Written for commit 83aa7bc. Summary will update on new commits.

Review in cubic

@pedrofrxncx
pedrofrxncx merged commit 4d5264e into main Jul 29, 2026
18 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/edit-route-async-w1 branch July 29, 2026 18:11
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).
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