Repository navigation
fix(qqbot): resolve start() when abort signal already fired - #109896
ZengWen-DT wants to merge 3 commits into
Conversation
|
Codex review: needs changes before merge. Reviewed August 4, 2026, 11:18 AM ET / 15:18 UTC. ClawSweeper reviewWhat this changesThe PR adds QQBot gateway abort checks after credential, gateway-URL, and WebSocket setup, with tests for pre-abort startup and late socket disposal. Merge readinessKeep this PR open: it usefully fences late QQBot resources after shutdown, but its startup promise still waits for an in-flight token request after abort, leaving a user-visible shutdown stall. Priority: P1 Review scores
Verification
How this fits togetherQQBot account startup obtains credentials, resolves a gateway URL, and opens a WebSocket that carries channel events. Gateway shutdown supplies an abort signal that must end startup promptly and prevent resources created afterward from becoming active. flowchart LR
A[Gateway account start] --> B[QQBot connection startup]
B --> C[Credential exchange]
C --> D[Gateway URL lookup]
D --> E[WebSocket creation]
E --> F[Active channel connection]
G[Shutdown abort signal] --> B
G --> E
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +21, Tests +54. Total +75 across 2 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep the late-resource guards, but make shutdown settle start immediately while the in-flight connection path finishes only enough work to fence and dispose late resources. Do we have a high-confidence way to reproduce the issue? Yes—use a deferred token exchange, abort after it begins, and assert that start settles before releasing the token; current source shows it instead waits for connect. Is this the best way to solve the issue? No—the late-resource guards are correct, but they do not make start settle while token acquisition remains pending; the lifecycle owner should observe shutdown concurrently. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against cb2965dddece. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
GatewayConnection.start() waited on an abort listener that never runs when the caller's AbortSignal is already aborted, leaving channel stop hung. Check abortSignal.aborted before registering the listener. Co-authored-by: Cursor <[email protected]>
1235f5e to
91379c2
Compare
ws.close() on a CONNECTING socket emits an error from abortHandshake(). Without a listener, Node treats it as unhandled and terminates the Gateway. Attach a noop error handler before disposal, and update the late-socket test to model real ws connecting-state error emission.
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
When the gateway stop AbortSignal is already aborted at construction
time, the addEventListener('abort', onAbort) listener never fires per
the AbortSignal spec. This leaves waitForExit pending forever, hanging
channel shutdown. The fix resolves onAbort immediately when
abortSignal.aborted is already true, matching the pre-aborted handling
pattern in WhatsApp connection-controller (openclaw#109903) and QQBot
gateway-connection (openclaw#109896).
Co-Authored-By: Claude <[email protected]>
|
Thanks for this fix! Unfortunately this PR is no longer landable here: QQBot was externalized in #107295 (landed as If the problem still exists in the external package's 2.x code, please port the patch to that repository — the maintainers there own this surface now. Closing as unlandable against current |
What Problem This Solves
Fixes an issue where stopping the QQBot gateway during or immediately after startup could leave
GatewayConnection.start()pending forever when the caller AbortSignal was already aborted. The previous lifecycle also continued connecting after an early abort, which could leave a socket created during shutdown outside cleanup ownership.Why This Change Was Made
start()registered abort listeners after work had already begun without normalizing an already-fired signal. The fix makes abort handling idempotent at registration, skips connection work for pre-aborted starts, and checks lifecycle ownership after each asynchronous startup stage. A socket created after an in-flight abort is closed before it can be adopted. Risk is limited to the QQBot connection startup and shutdown path; no config or protocol surface changes.User Impact
QQBot channel stop/restart no longer hangs when shutdown overlaps startup, and startup does not retain a WebSocket that finishes opening after its lifecycle owner has stopped.
Evidence
Live configured-account proof (redacted):
This ran the exported
GatewayConnectionwith the locally configured QQBot app ID and secret file, forced a fresh real QQ credential exchange, then aborted immediately after invokingstart(). The patched lifecycle resolved in 146 ms after the real credential request and stopped before gateway URL/socket adoption. The already-running live Gateway was left online, and no messages were sent.Deterministic before proof on the original implementation:
The same exported-class harness with a pre-aborted signal exceeded its 500 ms bound before the fix.
Focused regression tests:
Coverage now verifies both that a pre-aborted start performs no socket creation and that a socket returned after an in-flight abort is immediately closed.
Additional checks:
pnpm check:changedattempted to delegate its heavy lane to unavailable maintainer Testbox infrastructure and exited before running the remote check. Full type/lint/build gates are therefore left to GitHub Actions. A full active-service restart was not performed because it would disrupt the existing live channel.AI-assisted: Codex and Cursor; proof runs executed on this machine.