Repository navigation
fix(ui): keep gateway retry backoff on the monotonic clock - #190098
huwei-xydt wants to merge 4 commits into
Conversation
A wall-clock jump during pause made resume() compute a zero remaining delay and fire the reconnect callback immediately. Co-Authored-By: Claude Code <[email protected]>
|
🦞👀 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. |
Co-Authored-By: Claude Code <[email protected]>
|
Codex review: needs real behavior proof before merge. What this changesThis PR uses monotonic deadlines to preserve Control UI retry backoff across wall-clock corrections. Example: A context-report request fails, its 30-second retry is paused while hidden, and the wall clock advances one hour.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenanceRegression provenance — verified: source commit Merge readiness⛔ Blocked before merge - 1 item remains This PR addresses a current retry-timing defect with a focused change to the shared owner; no introduced correctness defect remains identified. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherControl UI read owners schedule callbacks through the shared Gateway retry owner, which converts a pending deadline into a browser timer when resumed. flowchart LR
A[Context report request] --> B[Transient failure]
B --> C[Shared retry owner]
D[Page visibility] --> C
E[Monotonic clock] --> C
C --> F[Browser timer]
F --> A
Technical reviewBest possible solution: Keep the existing retry owner and use the shared monotonic helpers for its process-local deadline. Do we have a high-confidence way to reproduce the issue? Current-main source directly shows that advancing Date.now beyond a retained deadline makes resume schedule a zero-delay retry; the contributor also reports a matching base failure, but this read-only review ran no target code. Is this the best way to solve the issue? The production change is the smallest complete repair: deadline creation and subtraction share the existing monotonic clock without adding state owners or changing retry policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7e8ba3d34d10. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +5, Tests +91. Total +96 across 3 files. Added test files: 1. View PR surface stats
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 HistoryReviewed November 1, 2026, 1:39 AM ET / 06:39 UTC (Revision 3). |
ClawSweeper asked for context-report visibility + wall-clock evidence beyond the bare retry-owner unit. Drive sessionContextReportsForGateway through a retryable sessions.usage failure, hide, jump Date by one hour, show, and assert the 30s backoff still holds. Co-Authored-By: Claude Code <[email protected]>
|
@clawsweeper re-review Added the requested context-report visibility + wall-clock production-path evidence on head
|
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review PR body Evidence now includes the production-path diagnostic for head
Regression committed: |
|
🦞👀 Re-review progress:
|
Match the existing visibility/backoff test harness (full fake timers, watch presented before refresh). Partial Date-only fake timers left a checks-ui shard with request count 0 after refresh. Co-Authored-By: Claude Code <[email protected]>
|
@clawsweeper re-review Head |
|
🦞👀 Re-review progress:
|
…ions (#190894) fix: measure durations, timeouts and cache ages with the monotonic clock Several timeouts, cache TTLs and retry backoffs measured elapsed time with the wall clock. When the system clock jumped (NTP correction, sleep and resume, manual change), they fired too early, never fired, or ignored server backoff. These callers now use the monotonic clock (`src/shared/monotonic-time.ts` in core, `performance.now()` in extensions). Stored and displayed timestamps stay on the wall clock, and SDK signatures and public epochs are unchanged. This sweep includes #190846, #190852, #190853, #187703, #187689, #187782, #187765, #189161, #189160 and #190098, with the contributors' commits kept for credit. Evidence: built Gateway, CLI and real Chromium, main twice and candidate twice, stepping only the process wall clock (`Date.now`); no system clock change. On main, a Discord deployment timeout aborted or overran after a 60-second step, the Chromium context popover retried after about 100 ms despite server backoff, and the `sessions.usage`, Pi session catalog and GitHub project caches refreshed too early or too late. With this change, each followed real elapsed time. Ordinary controls passed, and epoch timestamps were unchanged. Details: #190894 (comment). Thanks @Alix-007, @chengzhichao-xydt, @huwei-xydt. Co-authored-by: Alix-007 <[email protected]> Co-authored-by: chengzhichao-xydt <[email protected]> Co-authored-by: Claude Code <[email protected]> Co-authored-by: 胡伟0668000622 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…ions (openclaw#190894) fix: measure durations, timeouts and cache ages with the monotonic clock Several timeouts, cache TTLs and retry backoffs measured elapsed time with the wall clock. When the system clock jumped (NTP correction, sleep and resume, manual change), they fired too early, never fired, or ignored server backoff. These callers now use the monotonic clock (`src/shared/monotonic-time.ts` in core, `performance.now()` in extensions). Stored and displayed timestamps stay on the wall clock, and SDK signatures and public epochs are unchanged. This sweep includes openclaw#190846, openclaw#190852, openclaw#190853, openclaw#187703, openclaw#187689, openclaw#187782, openclaw#187765, openclaw#189161, openclaw#189160 and openclaw#190098, with the contributors' commits kept for credit. Evidence: built Gateway, CLI and real Chromium, main twice and candidate twice, stepping only the process wall clock (`Date.now`); no system clock change. On main, a Discord deployment timeout aborted or overran after a 60-second step, the Chromium context popover retried after about 100 ms despite server backoff, and the `sessions.usage`, Pi session catalog and GitHub project caches refreshed too early or too late. With this change, each followed real elapsed time. Ordinary controls passed, and epoch timestamps were unchanged. Details: openclaw#190894 (comment). Thanks @Alix-007, @chengzhichao-xydt, @huwei-xydt. Co-authored-by: Alix-007 <[email protected]> Co-authored-by: chengzhichao-xydt <[email protected]> Co-authored-by: Claude Code <[email protected]> Co-authored-by: 胡伟0668000622 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Control UI reconnect retries store their deadline with
Date.now(). When the wall clock jumps forward while a retry is paused (page hidden / visibility change),resume()computes a non-positive remaining delay and fires the reconnect callback immediately instead of honoring the exponential backoff.User Impact
After a clock correction, the UI can drop the 30s–5min reconnect backoff and hammer the Gateway with an immediate retry. Repair turns and reconnect storms keep their intended spacing across forward and backward wall-clock corrections.
Why This Change Was Made
Use the existing process-local monotonic helpers (
monotonicDeadlineAfter/remainingMonotonicMs) for the retry deadline. Wall-clock display and persistence are not involved; the deadline is only used forsetTimeoutafter pause/resume.Smallest scope: +7/−2 production lines and regressions on the bare owner plus the production context-report path.
Evidence
Owner unit (base red / fix green)
Base (
Date.nowdeadline) red:Fix green (
4 passed): backs off / cancel / reset / wall-clock jump during pause.Production path diagnostic (context-report visibility + clock correction)
Drives real
sessionContextReportsForGateway(the Control UI owner behindchat-context-report) — not a bare retry-owner mock.Scenario: retryable
sessions.usageUNAVAILABLE → hide (visibilitychange) → wall clock+1h(Dateonly; monotonic deadline unchanged) → show → assert remaining backoff still holds before the second request.Fix (
5a7bbb601a1) — green with diagnostic recording:Base (
578321c3fbdDate.now deadline) — red on the same production path:(at
visible+20000ms: wall-clock jump made remaining ≤ 0, so the secondsessions.usagefired immediately on resume instead of after ~30s.)Tests
ui/src/lib/gateway-retry.test.ts— owner wall-clock jump during pause.ui/src/lib/session-context-report.clock-jump.test.ts— production context-report path: transient failure, visibility pause, wall-clock correction, resumed request honors remaining backoff.vitest run src/lib/gateway-retry.test.ts src/lib/session-context-report.test.ts src/lib/session-context-report.clock-jump.test.ts→ 11/11 green on this head.Merge Danger
Low.
ui/src/lib/gateway-retry.tshas no open PR on this path. No schema, workflow, or public API change. Clock helper is already used across Control UI (src/shared/monotonic-time.ts). New test only exercises existing owners.