Repository navigation
fix(sandbox): make the daemon discard route async - #5471
Merged
Merged
Conversation
The discard() helper called fs.unlinkSync() while being invoked from an async HTTP handler, blocking the daemon's single-threaded event loop. Convert to async unlink so file deletion no longer stalls the health probe Studio polls (CONTRIBUTING.md rule #1). Behavior-preserving: same error handling and file deletion order, just async.
pedrofrxncx
enabled auto-merge (squash)
July 31, 2026 01:18
decocms Bot
pushed a commit
that referenced
this pull request
Jul 31, 2026
PR: #5471 fix(sandbox): make the daemon discard route async Bump type: patch - @decocms/sandbox (packages/sandbox/package.json): 1.28.4 -> 1.28.5 - deploy/helm/sandbox-env (chart 0.9.52) (deploy/helm/sandbox-env/values.yaml deploy/helm/sandbox-env/Chart.yaml): image.tag/appVersion -> 1.28.5 Deploy-Scope: both
This was referenced Jul 31, 2026
pedrofrxncx
added a commit
that referenced
this pull request
Jul 31, 2026
publish() called mkdtempSync while running on the daemon's single-threaded Bun event loop, blocking it for the duration of the syscall — the same class of bug already fixed for the discard route (#5471) and decofile-block validation (#5481). Continue that conversion here: mkdtemp (fs/promises), awaited from the already-async publish() path.
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.
Summary
Convert the
discard()helper function from synchronous to asynchronous, replacingfs.unlinkSync()withawait unlink(). This eliminates a blocking filesystem call that stalls the daemon's single-threaded event loop and can cause missed health probes, triggering sandbox teardown.Why
Daemon filesystem operations must not block the event loop (see CONTRIBUTING.md rule #1). The
/git/discardHTTP handler was calling a synchronous function that deleted files usingfs.unlinkSync(), which could block the health probe Studio polls at ~500ms intervals. A missed probe triggers sandbox destruction.Testing
Behavior-preserving change: error handling and file deletion order unchanged, only async conversion. All 51 tests in
daemon/routes/git.test.tspass, including 5 discard-specific tests covering:To verify locally:
bun test ./packages/sandbox/daemon/routes/git.test.ts bunx tsc --noEmit -p packages/sandbox/tsconfig.jsonCI runs the full suite.
Summary by cubic
Make the
/git/discardroute non-blocking by convertingdiscard()to async. This prevents event loop stalls that could cause missed health probes and sandbox teardown.fs.unlinkSync()withawait unlink()and madediscard()async.await discard(); behavior and error handling unchanged.Written for commit 3198d9f. Summary will update on new commits.