Repository navigation
v0.60.16.0 fix(persistence): bound async git children so a lost exit cannot strand consumer shutdown - #5787
Merged
Conversation
…nd consumer shutdown Bun 1.3.x drops one-shot pidfd and pipe events when a callback re-enters the event loop, as bun:test expect().resolves/.rejects does (oven-sh/bun#30301). An execFile child whose exit is dropped stays a zombie and its callback, and its own timeout, never fire. The persistence consumer's durability probe (isDurabilityHardenedAsync, async since v0.60.10.0) spawns two git children per git effect, so a test awaiting .rejects while effects drained could leave the effects worker waiting forever; consumer.stop() awaits that worker, so disposePersistenceConsumer and every later fixture in the file hung ("killed N dangling process" is Bun reporting the unreaped children at the timeout). Seen in managed-maintenance, persistence-reconcile and google-attachments E2E. execFileBounded settles from its own timer at the deadline or on abort and SIGKILLs the child. The durability probe and the persistence Git runner use it; the topology clone's exit wait also returns once its deadline kill fires.
…cannot strand consumer shutdown
|
😎 This pull request was merged. |
harjothkhara
added a commit
to harjothkhara/gbrain
that referenced
this pull request
Sep 30, 2026
Merges master's bounded async git children fix (garrytan#5787) into this branch. Non-absorption confirmed: master's diff between 7ef5165..bdc36d5 has no src/commands/sources.ts or test/sources.test.ts entry. Version-lockstep files bumped from 0.60.15.1 to 0.60.16.1; derived artifacts (template repo, plugin tree) regenerated. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
harjothkhara
added a commit
to harjothkhara/gbrain
that referenced
this pull request
Sep 30, 2026
Merges master's bounded async git children fix (garrytan#5787) into this branch. Non-absorption confirmed: docs/architecture/key-files/core-ai.md, src/core/ai/errors.ts, src/core/ai/recipes/openrouter.ts, and both this PR's test files are byte-identical between the pre-merge base and master's new head. Version-lockstep files bumped from 0.60.15.1 to 0.60.16.1; derived artifacts (template repo, plugin tree) regenerated. Agent-Id: agent-1ce06382-5a83-4028-99b7-7d86c5e1ed00
harjothkhara
added a commit
to harjothkhara/gbrain
that referenced
this pull request
Sep 30, 2026
Merges master's bounded async git children fix (garrytan#5787) into this branch. Non-absorption confirmed: master's diff between 7ef5165..bdc36d5 does not touch src/commands/doctor/bootstrap-checks.ts, src/core/pglite-lock.ts, src/core/bootstrap/uninstall.ts, or the export-surface goldens fixed in an earlier cycle. Version-lockstep files bumped from 0.60.15.1 to 0.60.16.1; derived artifacts (template repo, plugin tree) regenerated. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
garrytan
added a commit
that referenced
this pull request
Sep 30, 2026
…t parks the page Hosted CI's w5 "a healthy scan and contention never park" ended queued with git_unavailable and target_failures 2 on notes/page-7. Since #5787 a bounded git run that is aborted (consumer shutdown) or hits its deadline is SIGKILLed, which skips git's own lock cleanup, so the .git/index.lock of an interrupted add/commit failed every later attempt and was counted as a target failure (probe: SIGKILL leaves the lock 2/2, SIGTERM removes it 2/2). - A killed run removes the index lock it created (mtime at or after the run's start); the persistence owner runs the checkout's git under its native worktree lock, so that lock is its own. - An exit-128 failure with an index lock present is git_index_locked, retried as contention without counting toward parking, while the lock is younger than 10 minutes; an older lock fails as git_unavailable naming the path and the fix. test/persistence-effect-git-index-lock.test.ts fails on the previous code (3/3) and passes now; the SIGKILL case uses a git that takes the lock and hangs, so the abort always lands mid-write.
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.
This fixes the fleet-wide E2E hang: a few tests pass, Bun prints "killed 1 dangling process", then every remaining test in the file times out. It showed up today in
managed-maintenance,persistence-reconcileandgoogle-attachments-postgres, including on PRs based on pre-refactor master.Root cause. This is Bun 1.3.x bug oven-sh/bun#30301, fixed in 1.4.0. When a callback re-enters the event loop, which bun:test's
expect().resolves/.rejectsdoes, Bun drops the other pidfd and pipe events in the same poll batch. The child stays a zombie, and neitherexecFile's callback nor its built-intimeoutfires. The chain that hangs:isDurabilityHardenedAsync, called fromeffects.ts.await hardenedhangs, and the effects worker with it.PersistenceConsumer.stop()waits on the effects worker, sodisposePersistenceConsumerhangs too.On a reproduced hang the test database had zero sessions, and the hung process had exactly two
[git] <defunct>children. The async probe arrived in v0.60.10.0; refactor wave 1 did not introduce this.Fix.
execFileBounded(src/core/brain-repo-durability.ts) settles from its own timer at the deadline or on abort, and SIGKILLs the child. It no longer depends on Bun delivering the exit or pipe event.gitrunner (20 s) now use it, with the samegit_unavailablemapping as before.consumer.stop()stays an unbounded barrier, becauseengine.closedepends on it. Bounding the children is the fail-fast.Evidence.
test/bounded-child-exec.test.tsreproduces the dropped event deterministically. Against the old code the durability probe fails 2/2 and never settles; with the fix it passes on Bun 1.3.13.bun run ci:ubicloudonbcd72973bwas green: unit 2117, serial 350, slow 25, E2E 325, verify, gitleaks.bun run verifyis also green after the version bump.Follow-up (not in this PR). Moving CI to Bun ≥ 1.4 removes the whole class. Other async child waits, such as the minions supervisors, stay exposed until then.