Repository navigation
Recover one-way-stale remote daemon connections - #2359
Merged
ymichael merged 1 commit intoAug 24, 2026
Merged
Conversation
ymichael
deleted the
bb/fix-worktree-model-picker-loading-thr_67snhz37mn
branch
August 24, 2026 22:57
ymichael
added a commit
that referenced
this pull request
Aug 25, 2026
## What was wrong Heartbeat acknowledgement expiry was coupled to the older 60-second system-suspension log heuristic. With the landed 5-second heartbeat and 30-second acknowledgement lease, a heartbeat callback delayed for roughly 31–64 seconds saw the acknowledgement as expired before the delay qualified for suspension grace, so waking a healthy host forced an unnecessary `heartbeat-ack-timeout` reconnect. This is a follow-up to [PR #2359](#2359). ## What changed - Grant one fresh acknowledgement lease whenever the heartbeat timer gap itself exceeds the lease, independently of how the gap is classified for logging. - Keep the existing sub-minute heartbeat-delay warning and 60-second likely-suspension info classification unchanged. - Add regression coverage proving a 35-second gap does not reconnect immediately and that a genuinely dead return path still reconnects after the fresh lease expires. There are no wire-contract changes, so `HOST_DAEMON_PROTOCOL_VERSION` remains unchanged. ## How you verified The new regression failed before the production change with an immediate `(1013, "heartbeat-ack-timeout")` reconnect and passed afterward. ```sh pnpm exec turbo run test --filter=@bb/host-daemon --force --concurrency=1 -- src/server-connection.test.ts pnpm exec turbo run typecheck --filter=@bb/host-daemon --force --concurrency=1 pnpm exec turbo run test --filter=@bb/host-daemon --force --concurrency=1 pnpm exec turbo run build --filter=@bb/host-daemon --force --concurrency=1 pnpm exec oxfmt apps/host-daemon/src/server-connection.ts apps/host-daemon/src/server-connection.test.ts --check ``` - Focused current-`main` result: 13 tests passed; 7/7 Turbo tasks successful. - Host-daemon typecheck: 4/4 Turbo tasks successful. - Full host-daemon suite: 45 files and 555 tests passed; 7/7 Turbo tasks successful. - Host-daemon build: 5/5 Turbo tasks successful. Follow-up to #2358 and #2359. > AGENT GENERATED
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.
What was wrong
A remote host could lose only the server-to-daemon direction of its Connect-relayed WebSocket after sleep or a network transition while daemon-to-server heartbeats still arrived. The server therefore kept the host registered and sent host RPCs into a stale return path. Provider discovery amplified one unreachable host into two 30-second waves because four installed-only probes ran with concurrency three and each received a fresh command timeout. See #2358.
What changed
heartbeat-ack, andHOST_DAEMON_PROTOCOL_VERSIONis bumped from 164 to 165 so enrolled hosts update atomically with the wire change.How you verified
Added regression coverage that fails without the change:
heartbeat-ackCommands run after rebasing onto current
main:All 94 focused tests passed, and all three affected packages typechecked.
Fixes #2358