Repository navigation
Conversation
ymichael
deleted the
bb/ci-flake-fix-bb-app-tarball-daemon-port-collisio-thr_yc7s5evq5r
branch
September 11, 2026 03:32
ymichael
added a commit
that referenced
this pull request
Sep 15, 2026
## Human comments ## What was wrong The packaged smoke launched each long-running surface as a detached process-group leader, signaled the whole group during cleanup, but considered cleanup complete as soon as only the leader emitted `exit`. For `bb-server`, that leader is a launcher around the real server child: the launcher exits immediately on the group signal while the child handles the same signal with asynchronous plugin shutdown. In the failing [macOS Node 26 job](https://github.com/get-bb/bb/actions/runs/34905198646/job/104180134470), every assertion passed and the pass banner printed before recursive removal hit `ENOTEMPTY` in `join-server-data-1/plugins`. A later unchanged smoke passed, consistent with the descendant shutdown race. On the frozen Intel base, temporary instrumentation observed the old stop function return while the real server child was still running with PPID 1 in the leader's process group; a daemon group also still contained its parcel-watcher child. The outer `rm` could therefore race descendants that still owned the temporary data tree. ## What changed - Move managed-process shutdown into a focused script helper. - On POSIX, keep the existing group-wide `SIGINT`, five-second graceful deadline, and `SIGTERM` escalation, but resolve cleanup only after signal-0 observes that the entire process group is gone. - Preserve the existing child-exit behavior on Windows, where detached POSIX process groups are not used. - Add a real-process regression whose group leader exits immediately while a descendant completes asynchronous shutdown and writes a marker. The cleanup promise must wait for that marker-producing descendant. - Include MJS regression files in the existing bb-app Vitest project. There are no CLI, SDK, configuration, server/daemon wire, or protocol contract changes. `HOST_DAEMON_PROTOCOL_VERSION` remains 208 because the change is confined to the smoke harness's local process lifecycle. ## How you verified - Frozen-base gate: enrolled Intel host `host_nwqfteeqz4`, Intel Core i5-1038NG7, `x86_64`, clean initial worktree, and HEAD/origin/main/merge-base all `475f4d6239fdab634c0991bcf0e4da6508154807`. - Repeated GitHub searches for `ENOTEMPTY "directory not empty"`, `join-server-data-1/plugins`, `NOQCov`, and open bb-app tarball cleanup PRs returned no overlap. BB search found only this child and its parent as active owners. Merged PR #3459 was inspected; it addressed port reservation and fatal startup exit, not this cleanup boundary. - Before fix, a Node 26 installed-tarball observation captured `bb-server` leader PID 31862 exited while real server PID 31863 remained running with PPID 1 and PGID 31862. The unchanged smoke happened to pass in 109.5s, matching the intermittent nature of the main failure. - Red regression check: temporarily restoring leader-only waiting made `test/managed-process.test.mjs` fail with `ENOENT` because `descendant-finished` did not exist when cleanup returned. - Green Node 26 focused check: `pnpm exec turbo run test --filter=bb-app --force -- test/managed-process.test.mjs` — 1/1 test and 4/4 Turbo tasks passed. - Node 26 direct installed-tarball smoke — all existing assertions passed in 109.7s. - Node 26 `pnpm exec turbo run smoke:tarball --filter=bb-app --force --output-logs=new-only` — 50/50 tasks passed; tarball smoke passed in 108.8s. - `pnpm exec turbo run test --filter=bb-app --force --output-logs=new-only` — 6 files / 82 tests and 4/4 Turbo tasks passed. - `pnpm exec turbo run typecheck --filter=bb-app --force --output-logs=new-only` — 3/3 tasks passed. - `pnpm exec turbo run build --filter=bb-app --force --output-logs=new-only` — 49/49 tasks passed. - Prettier checks, Node syntax checks for all changed MJS files, and `git diff --check` passed. - Every build/test/smoke/probe used an external process-group deadline. Final bounded-smoke sentinels reported no remaining groups, and filesystem/process scans found no matching smoke, probe, fixture, or temporary directories. Limitation: the exact `ENOTEMPTY` did not recur in the bounded local full-smoke runs. The CI failure supplies the filesystem symptom; local old-code instrumentation directly observed the surviving actual descendants, and the focused fixture deterministically reproduced the premature completion contract without adding contention, retries, sleeps as cleanup, or deadline increases. > AGENT GENERATED: by GPT-5.6-Sol
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.
Human comments
What was wrong
The Linux Node 26 compatibility job reserved a unique set of smoke ports, closed every listener, and only then spawned the packaged server and daemons. That guaranteed uniqueness within the set but left every selected port unowned across the bind boundary. Because the reservation had successfully bound port 37357, the eventual owner necessarily acquired it after release; matrix jobs run on separate runners, so another matrix leg could not own it. A packaged Intel reproduction deliberately reclaimed the released daemon port and reproduced the second issue: the daemon reported
EADDRINUSE, but its top-level failure handler only assignedprocess.exitCode, so resources created before the failed local API bind kept the daemon child alive and the join launcher's readiness poll consumed its full 60-second deadline. The CI log cannot identify the short-lived competing process after the fact, but the reservation chronology proves the close-before-bind race regardless of that process's identity.What changed
EADDRINUSE/host-daemon collision diagnostics from the managed process and redirected service logs, clean the complete failed attempt, and retry at most three times with fresh ports and fresh data directories. Other startup failures remain failures./health, and additionally require the separate server's launch ID plus each daemon's connected/statusserver identity so a foreign HTTP 200 cannot satisfy readiness.The packaged launchers accept numeric ports and spawn the actual listeners in child/grandchild processes; they do not accept an inherited listening socket. Passing a bound descriptor through that public launch architecture would be a much broader contract change, so the smoke narrows the release window and retries only the positively identified bind race at the whole-attempt boundary. No timeout, retry interval, CLI contract, or server/daemon wire field changed.
How you verified
host_nwqfteeqz4,x86_64, Intel Core i5-1038NG7; original HEAD and required merge-basea4f513251851bc357fbc0f28e61c331ea3f9f2e4.origin/mainadvanced afterward, but the branch retained the instructed frozen base.exitCode=null, signalCode=nulltwo seconds later.daemon join port collision on attempt 1; retrying with fresh reservations, then passed the fresh separate server and two joined daemons in 10.2 seconds. The full packed-tarball smoke passed in 205.3 seconds.pnpm exec turbo run smoke:tarball --filter=bb-app --output-logs=new-only— 13/13 tasks; final committed harness passed in 116.5 seconds, including pack/install/repack, provider bridges, plugin worker, full stack, health/status identity, persisted server URL, and two joined daemons.pnpm exec turbo run test --filter=@bb/host-daemon --filter=bb-app --concurrency=2 --force— 50 host-daemon files / 591 tests and 4 bb-app files / 79 tests passed.pnpm exec turbo run typecheck --filter=@bb/host-daemon --filter=bb-app --force— 5/5 tasks passed.pnpm exec turbo run build --filter=bb-app— 12/12 tasks passed.pnpm exec prettier --check apps/host-daemon/src/index.ts apps/host-daemon/src/startup-diagnostics.test.ts packages/bb-app/scripts/smoke-tarball.mjs,node --check packages/bb-app/scripts/smoke-tarball.mjs, andgit diff --checkpassed.bb-app-tarball-*/bb-port-repro-*temp directories.