fix(sandbox): make daemon.json read async to stop blocking the event loop - #5336
Merged
Conversation
…loop readConfig() used readFileSync on the daemon's single-threaded Bun event loop. It runs from orchestrator.fillApplicationDefaults() during stepClone — a live-daemon path, not just boot — so every clone blocked the loop from answering its HTTP health probe for the duration of the read. Studio tears down a daemon on a single missed probe. Switch to node:fs/promises readFile and thread the await through both call sites (entry.ts hydrate, orchestrator.ts fillApplicationDefaults).
decocms Bot
pushed a commit
that referenced
this pull request
Jul 28, 2026
PR: #5336 fix(sandbox): make daemon.json read async to stop blocking the event loop Bump type: patch - @decocms/sandbox (packages/sandbox/package.json): 1.24.3 -> 1.24.4 - deploy/helm/sandbox-env (chart 0.9.35) (deploy/helm/sandbox-env/values.yaml deploy/helm/sandbox-env/Chart.yaml): image.tag/appVersion -> 1.24.4 Deploy-Scope: both
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.
Source: hardening follow-up — CONTRIBUTING.md rule #1 / CLAUDE.md gotcha #8 explicitly bans sync fs in
packages/sandbox/daemon/**because the daemon runs on a single-threaded Bun event loop and Studio tears the daemon down on a single missed health-probe response.Why it matters:
persistence.ts#readConfigusedreadFileSyncto load.decocms/daemon.json. It's not just a boot-time call —orchestrator.ts#fillApplicationDefaultscalls it duringstepClone, which runs on an already-serving daemon, so every repo clone blocked the event loop (and the health probe) for the duration of that synchronous read.Fix: switched
readConfigtonode:fs/promisesreadFileand made itasync, threadingawaitthrough both call sites (entry.ts'shydrate(), now itself async with a top-levelawait, andorchestrator.ts'sfillApplicationDefaults). Pure behavior-preserving conversion — same validation, same return shape, same error handling — just non-blocking. Updatedpersistence.test.tsto use the asyncnode:fs/promiseshelpers andawait readConfig(...).Reviewer check:
cd packages/sandbox && bunx tsc --noEmitandbun test packages/sandbox/daemon/persistence.test.ts.Verified locally:
bun run fmt,bunx tsc --noEmitinpackages/sandbox(green), and the targetedpersistence.test.ts(3 pass). Full CI covers the rest.Summary by cubic
Make reading
.decocms/daemon.jsonasync to stop blocking the daemon’s Bun event loop and prevent missed health probes during repo clones. Behavior is unchanged; the read is now non-blocking.readConfigtonode:fs/promises.readFileand made it async.awaittoentry.tshydrate()(top-levelawait) andsetup/orchestrator.tsfillApplicationDefaults().persistence.test.tsto asyncfsAPIs andawait readConfig.Written for commit 1284562. Summary will update on new commits.