fix(sandbox): make publish()'s untracked-dir expansion async - #5506
Open
pedrofrxncx wants to merge 1 commit into
Open
fix(sandbox): make publish()'s untracked-dir expansion async#5506pedrofrxncx wants to merge 1 commit into
pedrofrxncx wants to merge 1 commit into
Conversation
expandUntrackedDirs() called fs.statSync from inside the already-async publish() handler, blocking the daemon's single-threaded event loop for the syscall's duration on every publish that touches an untracked directory (e.g. a fresh .deco/blocks/ dir before its first commit) — stalling the /health probe Studio polls to detect a live sandbox. Swap fs.statSync for fs.promises.stat, awaited at the one call site. Behavior-preserving: same directory-vs-file detection, same fallback to false on a stat error.
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.
Continues the daemon's sync-fs → async-fs hardening pass (#5471 discard, #5481 decofile-block validation, #5497 hooks-dir mkdtemp) for the same reason: any blocking
*Syncfs call on the daemon's single-threaded Bun event loop stalls the/healthprobe Studio polls, which can get a live sandbox marked dead.Bug:
publish()'sexpandUntrackedDirs()helper calledfs.statSyncfrom inside the already-asyncpublish()handler.git status --porcelaincollapses an untracked directory into one?? dir/entry, so this runs on every publish that touches a fresh untracked directory — e.g. the very common case of a brand-new.deco/blocks/dir before its first commit — blocking the event loop for the syscall's duration.Fix: swap
fs.statSync(node:fs) forfs.promises.stat, awaited at the one call site insidepublish(). Behavior-preserving: same directory-vs-file detection, same fallback tofalseon a stat error (e.g. a raced deletion), same single call site. Net diff: +9/-3.Verify:
cd packages/sandbox && bunx tsc --noEmit(clean) andbun test packages/sandbox/daemon/routes/git.test.ts(51 pass) — several existing publish() tests (e.g. "publish() commits a valid decofile block") write directly into a fresh untracked.deco/blocks/dir, exercising this exact code path.Locally ran:
bun run fmt, targetedtsc --noEmitinpackages/sandbox, the single test file above, andbunx oxlint packages/sandbox/daemon/routes/git.ts(0 warnings/errors). Full CI validates the rest.Summary by cubic
Make publish()’s untracked-dir expansion async to avoid blocking the daemon’s event loop and stalling the /health probe. Replaces fs.statSync with fs.promises.stat to prevent stalls when publishing into fresh untracked dirs (e.g. .deco/blocks/).
Written for commit db9ca1d. Summary will update on new commits.