Repository navigation
Conversation
Greptile SummaryThis PR fixes a watchdog clock-reset bug in the Discord gateway reconnect lifecycle. The reconnect stall watchdog ( The fix introduces two
A new regression test directly exercises the 8-open-without-READY scenario and asserts the watchdog fires after the expected 5-minute deadline. Key changes:
Confidence Score: 5/5
Last reviewed commit: "Merge branch 'main' ..." |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b28ffc24a9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (!reconnectStallWatchdog.isArmed()) { | ||
| reconnectStallWatchdog.arm(at); |
There was a problem hiding this comment.
Reset the watchdog after brief READY reconnects
When a reconnect briefly reaches READY/RESUMED and then drops again before HELLO_CONNECTED_POLL_MS elapses, this close handler still sees gateway.isConnected === true (per the comment above) but now leaves the watchdog armed at the original disconnect timestamp. In that flappy-connection case, several successful reconnects can still accumulate toward the 5-minute cap and eventually raise reconnect watchdog timeout, which is a regression from the previous arm(at) behavior that effectively reset the clock on each successful reconnect cycle.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 05235acd4f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@greptileai recheck my code |
05235ac to
057ebf9
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 057ebf9925
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| let sawConnected = params.gateway?.isConnected === true; | ||
| if (sawConnected) { | ||
| reconnectStallWatchdog.disarm(); |
There was a problem hiding this comment.
Disarm watchdog as soon as socket opens
Fresh evidence from this patch: the unconditional disarm on "WebSocket connection opened" was removed and disarm now waits for sawConnected/the 250ms poll. In reconnects that recover just before the 5-minute deadline (READY flips gateway.isConnected shortly after open), reconnectStallWatchdog can remain armed long enough for its 5s checker (src/channels/transport/stall-watchdog.ts) to fire first and force-stop a connection that already recovered, because this branch keeps the old disconnect timestamp until the next poll tick.
Useful? React with 👍 / 👎.
|
Friendly bump — still open for review! |
Resolves conflicts from the carbon-native reconnect refactor (openclaw#59019): - Remove provider.lifecycle.reconnect.ts (deleted in refactor) - Accept rewritten provider.lifecycle.test.ts (watchdog tests no longer apply)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c598af5249
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (params.gateway?.isConnected) { | ||
| reconnectStallWatchdog.arm(at); | ||
| } else if (!reconnectStallWatchdog.isArmed()) { |
There was a problem hiding this comment.
Avoid resetting reconnect watchdog on every close event
The new close-handler logic still resets the watchdog clock whenever gateway.isConnected is truthy (reconnectStallWatchdog.arm(at)), even if the watchdog is already armed. In reconnect flapping where close debug events keep arriving with isConnected === true (the test suite already models close events while isConnected remains true), each close refreshes lastActivityAt, so the 5-minute watchdog may never expire and the monitor can stay disconnected indefinitely instead of force-stopping.
Useful? React with 👍 / 👎.
…122950 Add a disconnection watchdog to createGatewayStatusObserver in provider.lifecycle.ts — the existing lifecycle owner. When the gateway closes, the watchdog starts polling isConnected. If the gateway stays disconnected longer than runtimeReadyTimeoutMs, it calls triggerForceStop, which goes through the existing lifecycle cleanup path (waitForDiscordGatewayStop → finishReject → proper disconnect and listener cleanup). The watchdog self-clears when the gateway reconnects (isConnected becomes true) or when a new socket opens (Gateway websocket opened debug event). This moves recovery from a parallel timer in the lower-level gateway module to the existing provider lifecycle owner, as ClawSweeper requested. The existing startReadyWatch already handles 'opened but no READY' — this extends coverage to 'closed and reconnect stalled'. Removed the previous GatewayConnectionWatchdog from gateway.ts and gateway-lifecycle.ts (net -223 lines of old approach). Related: openclaw#51190 (same symptom, fixed in lifecycle owner by openclaw#51252), openclaw#120222 (event-loop stall root cause), openclaw#112698 (Codex app-server stall). Closes openclaw#122950
Fixes #51190
The reconnect stall watchdog was being disarmed on every
"WebSocket connection opened"debug event and re-armed (resetting its clock) on every close/stall. This meant the 5-minute deadline never expired during repeated open-without-READY cycles, leaving the channel stuck inrunning=true/connected=falseindefinitely.isArmed()guard)isConnectedis confirmed true (READY/RESUMED), not on WS openisArmed()guard on the stall-handler arm