Repository navigation
fix(gateway): retry restart continuation recovery - #90490
sahibzada-allahyar wants to merge 6 commits into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 2, 2026, 1:51 PM ET / 17:51 UTC. Summary PR surface: Source +74, Tests +113. Total +187 across 10 files. Reproducibility: yes. Current main source shows only a one-shot 1,250 ms restart-continuation recovery while failed session-delivery entries persist retry/backoff metadata; I did not run a live Telegram outage scenario. Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 findings
Review detailsBest possible solution: Make the retry loop shutdown-owned: stop scheduling after close starts, track and await or suppress any active recovery before channel teardown, keep the sentinel handoff ordering, then refresh real behavior proof for the latest lifecycle change. Do we have a high-confidence way to reproduce the issue? Yes. Current main source shows only a one-shot 1,250 ms restart-continuation recovery while failed session-delivery entries persist retry/backoff metadata; I did not run a live Telegram outage scenario. Is this the best way to solve the issue? No. The periodic retry direction is plausible for the missing wake, but the callback is fire-and-forget and not drained by the close path, so this is not yet the best lifecycle-safe fix. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 55ed57a4e39b. Label changesLabel justifications:
Evidence reviewedPR surface: Source +74, Tests +113. Total +187 across 10 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
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Pushed the lifecycle-owned retry repair in a5a31a0. Exact verification run after the patch: @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Pushed follow-up commit 6f2323e to address the periodic retry cutoff review. The periodic retry now uses a fresh cutoff instead of the startup maxEnqueuedAt, while the initial startup recovery remains guarded. Exact verification after the patch:
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Follow-up lint cleanup pushed in commit b5a8a7a.\n\nWhat changed:\n- Removed the now-unnecessary non-null assertions in src/gateway/server-runtime-services.test.ts after the mock call type was made explicit.\n- Test-only change; no production behavior changed.\n\nVerification run locally:\n\n |
vincentkoc
left a comment
There was a problem hiding this comment.
This retry direction is useful, but the current lifecycle is not safe enough to land. The fix needs to serialize restart-sentinel producer work with gateway shutdown; otherwise it can still deliver after close or lose restart state.
Findings:
-
P1: late-registered restart sidecar shutdown is not awaited. The new restart-sentinel sidecar can be created while close has already drained
runtimeState.postReadySidecars.stopPostReadySidecarsAfterCloseStarted()currently callsvoid postReadySidecar.stop()for late registration, so the async stop promise that waits forrestartSentinelWakePromisecan be dropped. That reopens the race where sentinel/queue work continues after shutdown proceeds. The sidecar needs to be registered before it can start, or late-stop promises need to be tracked and awaited by the close path. -
P1: the sentinel is removed before the restart notice has a durable handoff.
removeRestartSentinelFile()runs beforedeliverRestartSentinelNotice(). If shutdown aborts after removal and before the notice is enqueued/sent,deliverRestartSentinelNotice()exits on the aborted signal and there is no sentinel file or outbound queue row left. For notice-only sentinels, the in-memory wake dies with the closing process, so the restart/update result can be lost. Keep/restore the sentinel on abort or durably enqueue the notice before deleting the sentinel.
Best-fix verdict: not landable as a small PR. This should either narrow to retrying only pre-startup abandoned rows, or grow into an explicit lifecycle/ownership fix with shutdown-aware producer tracking and durable handoff ordering.
Address review findings on restart-continuation retry lifecycle: - P1: track and await stop() promises for sidecars registered after close started, instead of dropping them via void stop(). The restart-sentinel sidecar's stop() awaits the sentinel wake, so dropping it let producer work continue past shutdown. stopPostReadySidecarsAfterCloseStarted now returns the stop promises; the close path awaits them. - P1: remove the restart sentinel file only after the notice has a durable handoff (continuation enqueued/drained and notice delivered). Previously removal ran before delivery, so an abort in between lost the notice. Delivery is now at-least-once (replayed on next boot) rather than lost.
|
Thanks @vincentkoc — both P1s addressed in d455844: P1 — late-registered sidecar stop not awaited. P1 — sentinel removed before durable handoff. Added regression coverage: post-attach test asserts the stop promises are returned and stay pending until the sidecar's Re-requesting review when you have a moment. |
|
This pull request has been automatically marked as stale due to inactivity. |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(gateway): retry restart continuation recovery This is item 1/1 in the current shard. Shard 3/4. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
|
Closing due to inactivity. |
What changed
Fixes #76087
Real behavior proof
Behavior or issue addressed: Restart/session delivery recovery now runs the startup drain and then continues retrying deferred restart-continuation deliveries while the gateway process is alive. Before this PR,
recoverPendingSessionDeliveries()scheduled one startup recovery after1_250ms; after this PR, it also schedules a60_000msperiodic retry. This proof seeds a failed queued restart-continuation entry, waits past the first retry backoff, then invokes the registered gateway periodic retry callback and verifies the entry is acknowledged.Real environment tested: Local OpenClaw source checkout on Darwin 25.5.0 arm64, Node v26.0.0, pnpm 11.2.2, branch
fastino-76087-restart-continuation-retry.Exact steps or command run after this patch:
OPENCLAW_STATE_DIR.activateGatewayScheduledServices(), confirmed the60000ms periodic retry interval was registered, waited past the first5000ms backoff, invoked that periodic callback, and checked the queue again.pnpm test src/gateway/server-runtime-services.test.ts src/infra/session-delivery-queue.recovery.test.ts src/gateway/server-restart-sentinel.test.ts.git diff --check HEAD~1..HEAD.Evidence after fix: Terminal transcript from the failed-entry periodic retry probe:
Supplemental focused test output:
Observed result after fix: A failed pending restart-continuation session-delivery entry (
retryCount: 1,lastError: "Network request for sendMessage failed!") remained queued before the first backoff elapsed. After the branch-registered60000ms session-delivery periodic retry callback ran past the5000ms backoff, OpenClaw loggedRecovered session delivery ...and the pending queue became[].What was not tested: No live Telegram network outage or production gateway credential flow. No permanent Telegram API failure path; this proof exercises the gateway scheduler retry path and the durable session-delivery queue recovery path with an isolated local state directory.