Skip to content

fix(sandbox): make publish()'s untracked-dir stat check async - #5553

Open
pedrofrxncx wants to merge 1 commit into
mainfrom
fix/git-publish-expand-untracked-dirs-statsync-w1
Open

fix(sandbox): make publish()'s untracked-dir stat check async#5553
pedrofrxncx wants to merge 1 commit into
mainfrom
fix/git-publish-expand-untracked-dirs-statsync-w1

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Follows #5497 and #5481, which converted this same file's hooks-dir creation and decofile-block validation read from sync fs to async — one more sync-fs spot in packages/sandbox/daemon/routes/git.ts remained.

expandUntrackedDirs() (called from publish(), the daemon's git-publish route) used fs.statSync per changed path to detect an untracked directory that git status --porcelain collapsed into a single entry. Per CONTRIBUTING.md rule #1, any sync fs call in packages/sandbox/daemon/** blocks the daemon's single-threaded Bun event loop for its duration, which can make it miss its health probe — Studio then marks the sandbox dead and tears it down/triggers recovery on a single miss.

Why a maintainer wants this: publish() runs on every interactive publish and on shutdown sync, so this blocking call executes on a routine, frequently-hit path, not an edge case.

Change: expandUntrackedDirs is now async and uses stat from node:fs/promises instead of fs.statSync; its one call site in publish() now awaits it. No behavior change — same directory-detection logic, just non-blocking.

How to confirm: bun test packages/sandbox/daemon/routes/git.test.ts (51 tests, all passing, including the publish() coverage for untracked .deco/ directory expansion).

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


Summary by cubic

Make the untracked-dir stat check in the git publish route async to keep the daemon responsive. In packages/sandbox/daemon/routes/git.ts, expandUntrackedDirs now uses stat from node:fs/promises and publish() awaits it; no behavior change.

  • Bug Fixes
    • Eliminates a sync FS hotspot on the frequent publish/shutdown path, preventing Bun event loop blocking and reducing sandbox health probe misses.

Written for commit f5e81b8. Summary will update on new commits.

Review in cubic

expandUntrackedDirs() used fs.statSync per changed path inside publish(),
blocking the daemon's single Bun event loop while it runs. Convert it to
async, matching the same fix already applied to this file's hooks-dir
creation (#5497) and decofile-block read (#5481).

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

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