Repository navigation
fix(whatsapp): resolve abortPromise when stop signal already fired - #109903
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 17, 2026, 8:59 PM ET / July 18, 2026, 00:59 UTC. Summary PR surface: Source -5, Tests +49. Total +44 across 2 files. Reproducibility: yes. at controller level: constructing the controller with an already-aborted signal leaves the old listener-only abort promise unsettled, and the added regression test directly exercises the repaired path. A live WhatsApp/Baileys reproduction has not been supplied. Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Add redacted after-fix evidence from a real WhatsApp/Baileys startup-stop or rapid-restart flow that shows the affected account reaches shutdown rather than hanging, then refresh review on the exact head. Do we have a high-confidence way to reproduce the issue? Yes at controller level: constructing the controller with an already-aborted signal leaves the old listener-only abort promise unsettled, and the added regression test directly exercises the repaired path. A live WhatsApp/Baileys reproduction has not been supplied. Is this the best way to solve the issue? Yes, conditionally: using one abort callback for both signal states is the narrowest way to preserve identical cleanup and cancellation semantics. The remaining question is real channel behavior proof, not a different code design. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6f0f6af62e41. Label changesLabel justifications:
Evidence reviewedPR surface: Source -5, Tests +49. Total +44 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (7 earlier review cycles)
|
2d0cdb7 to
1804c8b
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
ee02e5a to
5c8159b
Compare
5c8159b to
a6c281e
Compare
waitForClose() races on abortPromise, but a pre-aborted gateway stop signal never settled that promise because the abort listener was skipped. Resolve abortPromise immediately when abortSignal.aborted is already true. Co-authored-by: Cursor <[email protected]>
…tPromise fix - Extract params.abortSignal to local const so tsgo can narrow the type through else-if control flow, fixing TS18048: possibly undefined - Remove setupAbortController/ownerAcquireAbortController.abort() from the constructor's pre-aborted branch so openConnection() still works when the stop signal was already fired at construction time - Use createSocketWithTransportEmitter() mock in the new test so shutdown() cleanup has sock.end() and ws.removeListener() available
a6c281e to
081ae6c
Compare
|
Merged via squash.
|
…penclaw#109903) * fix(whatsapp): resolve abortPromise when stop signal already fired waitForClose() races on abortPromise, but a pre-aborted gateway stop signal never settled that promise because the abort listener was skipped. Resolve abortPromise immediately when abortSignal.aborted is already true. Co-authored-by: Cursor <[email protected]> * fix(whatsapp): resolve tsgo TS18048 and test mock in pre-aborted abortPromise fix - Extract params.abortSignal to local const so tsgo can narrow the type through else-if control flow, fixing TS18048: possibly undefined - Remove setupAbortController/ownerAcquireAbortController.abort() from the constructor's pre-aborted branch so openConnection() still works when the stop signal was already fired at construction time - Use createSocketWithTransportEmitter() mock in the new test so shutdown() cleanup has sock.end() and ws.removeListener() available * fix(whatsapp): preserve pre-aborted setup cancellation * fix(whatsapp): unify connection abort handling --------- Co-authored-by: Cursor <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
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]>
What Problem This Solves
Fixes an issue where stopping a WhatsApp account during or immediately after connection startup would leave
WhatsAppConnectionController.waitForClose()pending forever when the gateway stopAbortSignalwas already aborted. Channel shutdown then waits on that race and never completes.Why This Change Was Made
The controller built
abortPromisewith anabortlistener but, when the signal was already aborted at construction time, only calledstopDisconnectRetries()and never settledabortPromise.waitForClose()races on that promise, so a pre-aborted stop signal could hang indefinitely. The fix resolvesabortPromiseimmediately whenabortSignal.abortedis already true, matching the existing pre-aborted handling for disconnect retries. Risk note: proof uses the exported controller with a synthetic open connection; live WhatsApp/Baileys sessions were not used.User Impact
WhatsApp channel stop/restart no longer hangs when shutdown is requested with an already-aborted stop signal (for example during fast gateway restarts or overlapping account lifecycle transitions).
Evidence
Before (upstream constructor on pre-aborted signal —
waitForClose()hangs):After (same harness with fix applied — resolves immediately):
The harness drives the exported
WhatsAppConnectionControllerwith a pre-abortedAbortController, injects an open connection whose close promise never settles, and raceswaitForClose()against a 500ms timeout.Focused tests:
What was not tested: Live WhatsApp WebSocket/Baileys session with production credentials; local harness proves the pre-aborted
abortPromisesettlement bug and fix on the real exported class.AI-assisted: Cursor Composer — proof runs executed manually on this machine.