fix(sandbox): make publish()'s untracked-dir stat check async - #5553
Open
pedrofrxncx wants to merge 1 commit into
Open
fix(sandbox): make publish()'s untracked-dir stat check async#5553pedrofrxncx wants to merge 1 commit into
pedrofrxncx wants to merge 1 commit into
Conversation
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.
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.tsremained.expandUntrackedDirs()(called frompublish(), the daemon's git-publish route) usedfs.statSyncper changed path to detect an untracked directory thatgit status --porcelaincollapsed into a single entry. Per CONTRIBUTING.md rule #1, any sync fs call inpackages/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:
expandUntrackedDirsis nowasyncand usesstatfromnode:fs/promisesinstead offs.statSync; its one call site inpublish()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, andbunx 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,expandUntrackedDirsnow usesstatfromnode:fs/promisesandpublish()awaits it; no behavior change.Written for commit f5e81b8. Summary will update on new commits.