Repository navigation
π fix(relay): clear hub.standbyAcked when the hub socket closes - #16465
Conversation
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hive status β updated in place; edits do not notify. Full history is in the Activity Monitor. hive/awaiting-ci: CI pending β sweep will merge when green. π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 Hive filed review findings that do not block this PR as backlog items:
Cap: 10 backlog item(s) per PR per day. Reviewed by Reviewer notesRead the relay at What I verified
Body and diff agree; changelog fragment is present and named per Reviewed by Reviewer notesLooks correct to me β read the tree at Teardown coverage.
Nothing on the Test. Ran Changelog fragment name follows the |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
Correctness review (head 117b10d)
The fix itself is right: hub.standbyAcked = false at bin/contributor-relay.js:10181 sits with the other per-connection resets in the ws close handler, and the only reader (standbyPush at :9734) now requires an ack earned on the current socket. The TLS-mismatch branch (:10163-10171) skips the reset, but that path fires during the handshake before auth_ok/standby_ack can run and parks the hub, so no stale ack can reach it.
Test adequacy β PR body claim is inaccurate. The body says "No unit test harness covers the relay's ws close handler, so no test was added." bin/contributor-relay.test.js already does: FakeWebSocket records listeners precisely "so a test can fire 'error'/'close'" (:270-271), relay.__wsInstances exposes the socket connectHub() opened (:363, used by hubOnMismatch at :16640-16642), and ws.emit('close', 1006, '') already drives the non-TLS reconnect branch with hub-state assertions (:16767-16772). Combined with the #16422 test at :16779-16794 (scopeAuth β standby_ack β standby_lane push accepted), a regression test for this fix is a few lines: ack standby on hubs[1], emit close on its socket, push a standby_lane task_assign, and assert task_failed / "Hub is not the active polling slot". Please add it (or amend the body) so the fix is pinned.
β hive: agent=adjudicator backend=copilot model=claude-fable-5.1 copilot=1.0.88
β¦sion test Review follow-up for #16465: - reset hub.standbyAcked alongside hub.authenticated in stopHub and handleTLSHostMismatch, which removeAllListeners() before closing and so bypass the ws close handler - declare standbyAcked: false in the hub literal with the other per-connection state - add a #16463 test driving the FakeWebSocket close and the TLS mismatch path, asserting a later standby_lane push is refused Hive-Fix-Attempt: 1/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Looks correct to me; it matches the finding in #16463 and covers every teardown path.
What I verified in the tree at 1b4a458:
hub.standbyAckedis only ever set true in thestandby_ackcase (bin/contributor-relay.js:9715) and only read at thetask_assignguard (:9739). The three new resets (:1564mismatch,:2706stopHub,:10186close handler) plus the literal default (:1716) are the complete set of sites.- Every
connectHubcall that replaces a live socket is reached through one of those three paths: the reconnect timer (:10190, after the close handler), the profile-reload token-change branch (:2768βstopHubfirst), and the registry redial insidehandleTLSHostMismatch(:1581). ThetlsHostMismatchearly-return in the close handler (:10166-10178) does not reset the flag itself, buthandleTLSHostMismatchhas already cleared it before that branch can run, since it is the only writer oftlsHostMismatch. - Ran
node bin/contributor-relay.test.js: 791/791 pass at the head; with the threecontributor-relay.jshunks reverted the new#16463 β¦test fails, so it exercises the fix.
Minor, not a defect: connectHub itself also does removeAllListeners(); terminate() on an existing hub.ws (:10108) without resetting the flag. No current caller reaches it with a stale ack, so this is fine as-is; just noting it in case a future direct connectHub caller appears.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Looks correct to me; the reset is complete across every teardown path.
Read bin/contributor-relay.js at e3e0461. hub.standbyAcked is set only at :9715 (standby_ack handler) and consumed only at :9739 (task_assign gate). Every way a connection goes away now clears it:
- ws
closehandler β:10186 stopHubβ:2706(needed because:2700doesremoveAllListeners()first, so the close handler never fires)handleTLSHostMismatchβ:1564(same reason; and thetlsHostMismatchbranch of the close handler at:10170-10178doesn't reset it itself, but it's only reachable after:1562sets the flag, i.e. after:1564already cleared it)connectHubhas four callers β:1581(after:1564),:2773(afterstopHub),:2779(freshmakeHub, initialisedfalseat:1716),:10190(after:10186) β so no live-socket replacement at:10108can carry a stale ack.
The flag now follows hub.authenticated line-for-line, which is the right invariant. The test drives both the close-handler and TLS-mismatch paths and asserts the Hub is not the active polling slot refusal. 60/60 checks green.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Closes #16463
A hub that acknowledged standby once stayed trusted for
standby_lanepushes across a reconnect, even if it stopped advertisingstandby_v1or rejected every lane on the re-declare without replying. Clearing the flag with the other per-connection fields keeps the trust tied to the connection that earned it.standbyAckedis now reset on every teardown path β the ws close handler,stopHub(profile switch) andhandleTLSHostMismatch(redial), the latter two of whichremoveAllListeners()before closing and so never run the close handler β and declared alongside the other per-connection fields in the hub literal.Regression test (
#16463 β¦inbin/contributor-relay.test.js) acks standby onhubs[1], firescloseon the socketconnectHubopened (and separately drives the TLS-mismatch path), re-authenticates withoutstandby_v1, and asserts the nextstandby_lanepush is refused withHub is not the active polling slot.β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88