Repository navigation
fix(sandbox): make installProtectedBranchHook async - #4452
Merged
Merged
Conversation
mkdirSync/writeFileSync/chmodSync block the daemon's single event loop (CONTRIBUTING.md rule #4) — a single missed health probe flips a healthy sandbox to crashed and tears the pod down mid-session. #4440 just added a second call site for this function (after every real install), doubling the exposure. Switch to node:fs/promises and await both call sites.
decocms Bot
pushed a commit
that referenced
this pull request
Jul 11, 2026
PR: #4452 fix(sandbox): make installProtectedBranchHook async Bump type: patch - @decocms/sandbox (packages/sandbox/package.json): 1.14.0 -> 1.14.1 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
Bug found reading recently-changed sandbox daemon code (#4440 added a second call site to
installProtectedBranchHook).Why
installProtectedBranchHookusedmkdirSync/writeFileSync/chmodSync(packages/sandbox/daemon/git/protect-branch.ts). The daemon runs on a single Bun event loop, and this repo's ownCONTRIBUTING.mdrule #4 (andCLAUDE.mdgotcha #8) calls out sync fs in this package as a hard rule, not a style nit: a single missed health probe flips a healthy sandbox to "crashed" and tears the pod down mid-session. #4440 just added a second call site for this same function (reinstalling the hook right after every realinstallcompletes, in addition to the existinggitSetup()call), doubling how often this sync work runs on the hot path.Fix
Switch
installProtectedBranchHooktonode:fs/promises(mkdir/writeFile/chmod) andawaitit at both call sites inorchestrator.ts(both are already insideasyncmethods withtry/catch, so this is a drop-in change).Test plan
bun test packages/sandbox/daemon/git/protect-branch.test.ts— 2 passbun test packages/sandbox/daemon/setup/orchestrator.test.ts— 12 pass, including the "reinstalls the pre-push hook after an install script clobbers it" regression test added by fix(sandbox): reinstall pre-push branch-protection hook after install #4440bun run fmt— cleanFull CI will validate the rest (typecheck across the monorepo needs
bun install, which I didn't run since this diff touches no dependencies).Summary by cubic
Make branch-protection hook installation async to stop blocking the sandbox daemon’s event loop. This prevents missed health probes and improves reliability during setup and post-install.
installProtectedBranchHookto usenode:fs/promisesand made itasync(mkdir/writeFile/chmod).SetupOrchestratorcall sites so reinstalling happens without blocking.await installProtectedBranchHook.Written for commit 6515f8b. Summary will update on new commits.