Skip to content

fix(sandbox): make the daemon's publish hooks-dir creation async - #5497

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/git-publish-async-hooksdir-w2
Jul 31, 2026
Merged

pedrofrxncx merged 1 commit into
mainfrom
fix/git-publish-async-hooksdir-w2

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 31, 2026 •

Copy link
Copy Markdown
Collaborator

Continues the daemon's sync-fs → async-fs hardening pass (#5471 discard, #5481 decofile-block validation) for the same reason: any blocking *Sync fs call on the daemon's single-threaded Bun event loop stalls the /health probe Studio polls, which can get the sandbox marked dead.

Bug: publish()'s getEmptyHooksDir() called mkdtempSync (creating the empty core.hooksPath dir used to skip lefthook/husky on the publish commit) from inside the already-async publish() handler, blocking the loop for the syscall's duration on the first publish of the daemon's lifetime.

Fix: swap mkdtempSync (node:fs) for mkdtemp (node:fs/promises), awaited at the one call site inside publish(). Behavior-preserving — same memoized dir, same path, same commit args; only the creation is now async. Net diff: +6/-5.

Verify: cd packages/sandbox && bunx tsc --noEmit (clean) and bun test packages/sandbox/daemon/routes/git.test.ts (51 pass, including the publish-path tests that exercise this helper).

Locally ran: bun run fmt, targeted tsc --noEmit in packages/sandbox, the single test file above, and bunx oxlint packages/sandbox/daemon/routes/git.ts (0 warnings/errors). Full CI validates the rest.


Summary by cubic

Made hooks directory creation in the sandbox daemon’s publish path async to avoid blocking the Bun event loop. This keeps the /health probe responsive and prevents the sandbox from being marked dead.

  • Bug Fixes
    • Replaced mkdtempSync (node:fs) with awaited mkdtemp (node:fs/promises) in publish() and passed it to core.hooksPath.
    • Behavior preserved: the empty hooks dir is still memoized and used to skip lefthook/husky during publish commits.

Written for commit 549fe42. Summary will update on new commits.

Review in cubic

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.
@pedrofrxncx
pedrofrxncx enabled auto-merge (squash) July 31, 2026 15:18
@pedrofrxncx
pedrofrxncx merged commit f208058 into main Jul 31, 2026
24 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/git-publish-async-hooksdir-w2 branch July 31, 2026 15:35
decocms Bot pushed a commit that referenced this pull request Jul 31, 2026
PR: #5497 fix(sandbox): make the daemon's publish hooks-dir creation async
Bump type: patch

- @decocms/sandbox (packages/sandbox/package.json): 1.28.6 -> 1.28.7
- deploy/helm/sandbox-env (chart 0.9.54) (deploy/helm/sandbox-env/values.yaml deploy/helm/sandbox-env/Chart.yaml): image.tag/appVersion -> 1.28.7

Deploy-Scope: both
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