Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesThe PR limits Discord startup readiness failures to ten timeouts, reports exhaustion, and adds a regression test for handing failure to the account restart supervisor. Review scores
Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 4 items remain This remains useful work for an unresolved Discord recovery problem, but the new exhaustion path leaves the old transport running and the PR lacks real recovery proof. Priority: P1 Before merge
Findings
Agent review detailsHow this fits togetherThe Discord lifecycle waits for the bot connection to become ready and publishes account health. Failed provider tasks reach the Gateway’s account supervisor, which can start a replacement Discord client. flowchart TD
A[Discord connection] --> B[Wait for readiness]
B --> C{Ready before retry limit}
C -->|Yes| D[Receive Discord events]
C -->|No| E[Stop old transport]
E --> F[Account restart supervisor]
F --> A
Technical reviewBest possible solution: Give lifecycle teardown responsibility for stopping the old transport before account recreation, while preserving transient retries and accurate recovery status. Do we have a high-confidence way to reproduce the issue? Yes from source: ten startup timeouts reach the new throw while bypassing the only normal lifecycle disconnect path. No runtime reproduction or tests were executed in this read-only review. Is this the best way to solve the issue? The bounded handoff is appropriate, but the patch is incomplete because it assumes cleanup stops a transport that it actually leaves running. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b58f2a2c3327. Merge-risk optionsMaintainer options:
SecurityNone. EvidenceWhat I checked:
PR surfaceSource +17, Tests +25. Total +42 across 2 files. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 1, 2026, 12:15 AM ET / 04:15 UTC. |
Root cause: extensions/discord/src/internal/gateway-identify-limiter.ts:10 reserved the shared 5 s IDENTIFY window as soon as a socket started waiting, even when that socket was replaced before its turn, so with four or more Discord accounts retrying READY the abandoned reservations pushed the queue further ahead of real time on every retry and the waiting accounts never sent IDENTIFY again. Fixes #162189 ## What Problem This Solves After a network or DNS outage, a Gateway running several Discord bot accounts could bring only some of them back. The rest kept logging `gateway READY wait timed out ... reconnecting with backoff` for hours and only recovered after a full Gateway restart. Thanks @mattreyes0824 for the detailed report: the untouched `session_start_limit` on the stuck accounts (they never sent IDENTIFY) pointed straight at this. ## User Impact Every Discord account reconnects and receives messages again once the network comes back, without restarting the Gateway. ## Why This Change Was Made All Discord accounts in one Gateway share one IDENTIFY pacing window (one IDENTIFY per 5 s). It handed out the next slot to whoever started waiting, before knowing whether that caller would still identify. When the network returns, each stuck account reconnects every ~17 s (15 s READY wait plus 2 s backoff) and joins the queue again; its previous wait is abandoned because the socket was replaced, but its slot stayed reserved. With four or more accounts the queue grows faster than time passes, every waiter is replaced before its turn, and the queue never drains. A process restart was the only thing that reset it, which matches the report (3 of 7 accounts recovered, 4 never identified). Now a slot is claimed only by an IDENTIFY that is actually sent, so replaced sockets leave the window free for the next live one. The window also uses the monotonic clock, so a wall-clock step cannot stall it. This replaces #162377 (thanks @yashas-13 for the first fix attempt): it bounded the READY retries and restarted the account, but the restarted account joins the same process-wide queue, which is still pushed far ahead. The proof below shows this directly: on main the health monitor already restarts the stuck accounts with a fresh client, and they still never send IDENTIFY. ## Evidence Real Gateway (`ocx src`, source tier, plus one branch run on the built `dist/` under Node) with 7 Discord accounts pointed through `DISCORD_API_URL` at a local Discord REST + Gateway stand-in. The stand-in drops every Gateway WebSocket for 100 s while the accounts start, then accepts them again; it logs each IDENTIFY it receives. Two runs per side plus a control, on merge base 3bc20e2 and branch head db4528e: - Before (main): after the network returned, only 3 of 7 accounts sent IDENTIFY; the other 4 sent none in the next 5 minutes and kept timing out on READY (both runs). In run 2 they still reported `connected=false` after the health monitor restarted them. Control with 3 accounts on main: all recover, as the queue can keep up. - After (this branch): all 7 accounts sent IDENTIFY within about 30 s, 5 s apart, and the READY timeouts stopped (both source runs and the built Node run); run 2 and the Node run report every account `connected=true`. - The focused gateway regression test fails on main and passes here. Proof lines: #201415 (comment) (main vs branch, two runs each, control, Node run) and #201415 (comment) (rerun on the exact head 93ca882). Merge danger: two-way door. The change is local to Discord IDENTIFY pacing and writes no state; a revert fully restores the old behavior. Blast radius if wrong: Discord accounts identifying too fast (rate limited) or too slowly at startup. Co-authored-by: Ayaan Zaidi <[email protected]>
|
Thank you @yashas-13 for working on this. The root cause turned out to be the shared Discord IDENTIFY limiter: it booked a slot as soon as a socket started waiting and kept it when that socket was replaced, so with several accounts retrying READY every slot was booked ahead and no socket ever sent IDENTIFY, even after an account restart. #201415 (cf5cf7a) books the slot only when IDENTIFY is actually sent; in a 7-account outage test all accounts reconnected within about 30 s. Bounding the READY retries alone would still leave restarted accounts behind the same booked queue, so I'm closing this one as covered, with thanks for the early diagnosis. |
…w#201415) Root cause: extensions/discord/src/internal/gateway-identify-limiter.ts:10 reserved the shared 5 s IDENTIFY window as soon as a socket started waiting, even when that socket was replaced before its turn, so with four or more Discord accounts retrying READY the abandoned reservations pushed the queue further ahead of real time on every retry and the waiting accounts never sent IDENTIFY again. Fixes openclaw#162189 ## What Problem This Solves After a network or DNS outage, a Gateway running several Discord bot accounts could bring only some of them back. The rest kept logging `gateway READY wait timed out ... reconnecting with backoff` for hours and only recovered after a full Gateway restart. Thanks @mattreyes0824 for the detailed report: the untouched `session_start_limit` on the stuck accounts (they never sent IDENTIFY) pointed straight at this. ## User Impact Every Discord account reconnects and receives messages again once the network comes back, without restarting the Gateway. ## Why This Change Was Made All Discord accounts in one Gateway share one IDENTIFY pacing window (one IDENTIFY per 5 s). It handed out the next slot to whoever started waiting, before knowing whether that caller would still identify. When the network returns, each stuck account reconnects every ~17 s (15 s READY wait plus 2 s backoff) and joins the queue again; its previous wait is abandoned because the socket was replaced, but its slot stayed reserved. With four or more accounts the queue grows faster than time passes, every waiter is replaced before its turn, and the queue never drains. A process restart was the only thing that reset it, which matches the report (3 of 7 accounts recovered, 4 never identified). Now a slot is claimed only by an IDENTIFY that is actually sent, so replaced sockets leave the window free for the next live one. The window also uses the monotonic clock, so a wall-clock step cannot stall it. This replaces openclaw#162377 (thanks @yashas-13 for the first fix attempt): it bounded the READY retries and restarted the account, but the restarted account joins the same process-wide queue, which is still pushed far ahead. The proof below shows this directly: on main the health monitor already restarts the stuck accounts with a fresh client, and they still never send IDENTIFY. ## Evidence Real Gateway (`ocx src`, source tier, plus one branch run on the built `dist/` under Node) with 7 Discord accounts pointed through `DISCORD_API_URL` at a local Discord REST + Gateway stand-in. The stand-in drops every Gateway WebSocket for 100 s while the accounts start, then accepts them again; it logs each IDENTIFY it receives. Two runs per side plus a control, on merge base d28eb7d and branch head db4528e: - Before (main): after the network returned, only 3 of 7 accounts sent IDENTIFY; the other 4 sent none in the next 5 minutes and kept timing out on READY (both runs). In run 2 they still reported `connected=false` after the health monitor restarted them. Control with 3 accounts on main: all recover, as the queue can keep up. - After (this branch): all 7 accounts sent IDENTIFY within about 30 s, 5 s apart, and the READY timeouts stopped (both source runs and the built Node run); run 2 and the Node run report every account `connected=true`. - The focused gateway regression test fails on main and passes here. Proof lines: openclaw#201415 (comment) (main vs branch, two runs each, control, Node run) and openclaw#201415 (comment) (rerun on the exact head 93ca882). Merge danger: two-way door. The change is local to Discord IDENTIFY pacing and writes no state; a revert fully restores the old behavior. Blast radius if wrong: Discord accounts identifying too fast (rate limited) or too slowly at startup. Co-authored-by: Ayaan Zaidi <[email protected]>
Root cause: extensions/discord/src/internal/gateway-identify-limiter.ts:10 reserved the shared 5 s IDENTIFY window as soon as a socket started waiting, even when that socket was replaced before its turn, so with four or more Discord accounts retrying READY the abandoned reservations pushed the queue further ahead of real time on every retry and the waiting accounts never sent IDENTIFY again. Fixes #162189 ## What Problem This Solves After a network or DNS outage, a Gateway running several Discord bot accounts could bring only some of them back. The rest kept logging `gateway READY wait timed out ... reconnecting with backoff` for hours and only recovered after a full Gateway restart. Thanks @mattreyes0824 for the detailed report: the untouched `session_start_limit` on the stuck accounts (they never sent IDENTIFY) pointed straight at this. ## User Impact Every Discord account reconnects and receives messages again once the network comes back, without restarting the Gateway. ## Why This Change Was Made All Discord accounts in one Gateway share one IDENTIFY pacing window (one IDENTIFY per 5 s). It handed out the next slot to whoever started waiting, before knowing whether that caller would still identify. When the network returns, each stuck account reconnects every ~17 s (15 s READY wait plus 2 s backoff) and joins the queue again; its previous wait is abandoned because the socket was replaced, but its slot stayed reserved. With four or more accounts the queue grows faster than time passes, every waiter is replaced before its turn, and the queue never drains. A process restart was the only thing that reset it, which matches the report (3 of 7 accounts recovered, 4 never identified). Now a slot is claimed only by an IDENTIFY that is actually sent, so replaced sockets leave the window free for the next live one. The window also uses the monotonic clock, so a wall-clock step cannot stall it. This replaces #162377 (thanks @yashas-13 for the first fix attempt): it bounded the READY retries and restarted the account, but the restarted account joins the same process-wide queue, which is still pushed far ahead. The proof below shows this directly: on main the health monitor already restarts the stuck accounts with a fresh client, and they still never send IDENTIFY. ## Evidence Real Gateway (`ocx src`, source tier, plus one branch run on the built `dist/` under Node) with 7 Discord accounts pointed through `DISCORD_API_URL` at a local Discord REST + Gateway stand-in. The stand-in drops every Gateway WebSocket for 100 s while the accounts start, then accepts them again; it logs each IDENTIFY it receives. Two runs per side plus a control, on merge base 3bc20e2 and branch head db4528e: - Before (main): after the network returned, only 3 of 7 accounts sent IDENTIFY; the other 4 sent none in the next 5 minutes and kept timing out on READY (both runs). In run 2 they still reported `connected=false` after the health monitor restarted them. Control with 3 accounts on main: all recover, as the queue can keep up. - After (this branch): all 7 accounts sent IDENTIFY within about 30 s, 5 s apart, and the READY timeouts stopped (both source runs and the built Node run); run 2 and the Node run report every account `connected=true`. - The focused gateway regression test fails on main and passes here. Proof lines: #201415 (comment) (main vs branch, two runs each, control, Node run) and #201415 (comment) (rerun on the exact head 93ca882). Merge danger: two-way door. The change is local to Discord IDENTIFY pacing and writes no state; a revert fully restores the old behavior. Blast radius if wrong: Discord accounts identifying too fast (rate limited) or too slowly at startup. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit cf5cf7a) Co-authored-by: RomneyDa <[email protected]>
…w#201415) Root cause: extensions/discord/src/internal/gateway-identify-limiter.ts:10 reserved the shared 5 s IDENTIFY window as soon as a socket started waiting, even when that socket was replaced before its turn, so with four or more Discord accounts retrying READY the abandoned reservations pushed the queue further ahead of real time on every retry and the waiting accounts never sent IDENTIFY again. Fixes openclaw#162189 ## What Problem This Solves After a network or DNS outage, a Gateway running several Discord bot accounts could bring only some of them back. The rest kept logging `gateway READY wait timed out ... reconnecting with backoff` for hours and only recovered after a full Gateway restart. Thanks @mattreyes0824 for the detailed report: the untouched `session_start_limit` on the stuck accounts (they never sent IDENTIFY) pointed straight at this. ## User Impact Every Discord account reconnects and receives messages again once the network comes back, without restarting the Gateway. ## Why This Change Was Made All Discord accounts in one Gateway share one IDENTIFY pacing window (one IDENTIFY per 5 s). It handed out the next slot to whoever started waiting, before knowing whether that caller would still identify. When the network returns, each stuck account reconnects every ~17 s (15 s READY wait plus 2 s backoff) and joins the queue again; its previous wait is abandoned because the socket was replaced, but its slot stayed reserved. With four or more accounts the queue grows faster than time passes, every waiter is replaced before its turn, and the queue never drains. A process restart was the only thing that reset it, which matches the report (3 of 7 accounts recovered, 4 never identified). Now a slot is claimed only by an IDENTIFY that is actually sent, so replaced sockets leave the window free for the next live one. The window also uses the monotonic clock, so a wall-clock step cannot stall it. This replaces openclaw#162377 (thanks @yashas-13 for the first fix attempt): it bounded the READY retries and restarted the account, but the restarted account joins the same process-wide queue, which is still pushed far ahead. The proof below shows this directly: on main the health monitor already restarts the stuck accounts with a fresh client, and they still never send IDENTIFY. ## Evidence Real Gateway (`ocx src`, source tier, plus one branch run on the built `dist/` under Node) with 7 Discord accounts pointed through `DISCORD_API_URL` at a local Discord REST + Gateway stand-in. The stand-in drops every Gateway WebSocket for 100 s while the accounts start, then accepts them again; it logs each IDENTIFY it receives. Two runs per side plus a control, on merge base 3bc20e2 and branch head db4528e: - Before (main): after the network returned, only 3 of 7 accounts sent IDENTIFY; the other 4 sent none in the next 5 minutes and kept timing out on READY (both runs). In run 2 they still reported `connected=false` after the health monitor restarted them. Control with 3 accounts on main: all recover, as the queue can keep up. - After (this branch): all 7 accounts sent IDENTIFY within about 30 s, 5 s apart, and the READY timeouts stopped (both source runs and the built Node run); run 2 and the Node run report every account `connected=true`. - The focused gateway regression test fails on main and passes here. Proof lines: openclaw#201415 (comment) (main vs branch, two runs each, control, Node run) and openclaw#201415 (comment) (rerun on the exact head 93ca882). Merge danger: two-way door. The change is local to Discord IDENTIFY pacing and writes no state; a revert fully restores the old behavior. Blast radius if wrong: Discord accounts identifying too fast (rate limited) or too slowly at startup. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit cf5cf7a) Release adaptation: None; migrate limiter and all gateway callers together. Co-authored-by: RomneyDa <[email protected]>
Closes #162189
Summary
startup-recovery-exhaustedstatus and add a focused regression testRoot cause
After a Discord DNS/network outage, the READY wait loop could reconnect the same client indefinitely after the network recovered. The reported installation remained in READY-wait retries for hours and only recovered after a full Gateway restart.
Fix
After 10 consecutive startup READY timeouts, the lifecycle now reports
startup-recovery-exhaustedand throws a bounded lifecycle error instead of reconnecting forever. The existing provider lifecycle cleanup path remains responsible for tearing down the client; the outer provider supervisor can then recreate the provider.Normal transient recovery is unchanged for attempts 1–9, and successful READY still clears the recovery state.
Regression
Added a lifecycle test proving:
startup-recovery-exhausted.No local test execution is claimed; validation is delegated to CI.