Repository navigation
fix(discord): annotate deploy request duration across clock changes - #189161
chengzhichao-xydt wants to merge 1 commit into
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 maintainer review before merge. What this changesMeasures Discord command-deployment request duration with a monotonic clock so clock corrections do not distort failure diagnostics. Example: A Discord command-list request times out after one second while the wall clock moves backward one hour.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current-main diagnostic bug with a focused change; the previous fixture finding is resolved and no correctness blockers remain. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherDiscord startup invokes Client command reconciliation, whose REST failures carry timing annotations into the deployment warning formatter. flowchart LR
A[Discord startup] --> B[Client command reconciliation]
B --> C[REST request owner]
C --> D[Discord REST transport]
D --> E[Annotated failure]
E --> F[Deployment warning formatter]
Technical reviewBest possible solution: Keep monotonic duration measurement in Client.requestCommandDeploy while preserving the existing annotation and formatter contracts. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the faulty wall-clock subtraction and its classification consumer; contributor output demonstrates the failure against base without this review executing target code. Is this the best way to solve the issue? The two clock replacements repair elapsed-time measurement at its existing owner, and the regression plus migrated consumer fixture cover the affected contract without introducing another timing layer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3bc6c4c43fc4. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +2, Tests +26, Other +2. Total +30 across 4 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
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 HistoryReview history (1 earlier review cycle)
Reviewed October 31, 2026, 6:36 AM ET / 10:36 UTC (Revision 2). |
Co-Authored-By: Claude Code <[email protected]>
e0facbc to
ac1bafb
Compare
|
Fixed the missed consumer fixture: |
|
@clawsweeper re-review |
|
🦞👀 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
Fixes: a failed discord slash-command deploy reports a bogus request duration in its error text when the system clock steps mid-request (NTP correction, manual change, VM snapshot restore).
requestCommandDeployannotates abort failures withdeployRequestMscomputed fromDate.now(), so a forward step reports a one-second timeout as an hour (observed=3600s), and a backward step zeroes the duration and even flips the diagnostic from "timed out" to "was aborted".User Impact
Deploy failure diagnostics report the real elapsed request time and classify timeout-vs-abort correctly regardless of clock corrections. No configuration, public API, schema, or migration changes; annotation field names and message shape are unchanged.
Why This Change Was Made
The annotation is a duration measurement, so it now reads
performance.now(), which is monotonic and immune to system-clock steps. A new regression pins an abort landing after a backward wall-clock step (duration stays 45ms on the monotonic clock instead of negative by an hour).Evidence
node scripts/run-vitest.mjs run extensions/discord/src/internal/command-deploy.test.ts: 4/4 pass (the new wall-clock regression is red against the base implementation).oxlintandoxfmt --checkclean on changed files. Local tsgo lane unavailable on this host (glibc 2.28 vs binary requirement 2.33+); type gates run in hosted CI. Net test growth +26 lines is recorded inconfig/test-lines-allocations/chengzhichao-discord-deploy-clock-20261031.txt.Real behavior proof
Behavior addressed: Deploy failure annotations must report real elapsed request time across wall-clock steps.
Real environment tested: This branch at HEAD
ac1bafb493a0ac997d498a68b5c789e99f296836, Node v24.13.1, Linux x64. A real subprocess constructs the real internalClientwith its REST base URL pointed at a real loopback HTTP server that hangs, so the request aborts at the configured real 1s timeout;Date.nowis stepped one hour when the request arrives (mid-flight) whileperformance.nowstays native. The observable is the shippedformatDiscordDeployErrorMessageoutput text.Exact steps or command run after this patch:
WT=$PWD STEP_MS=3600000 OUT=/tmp/clock-proof/deploy-head-fwd.json node --import tsx /tmp/clock-proof/discord-deploy.mtsandSTEP_MS=-3600000, then the same two commands withextensions/discord/src/internal/client.tsrestored to the base revision.Evidence after fix: HEAD (both directions):
Discord REST GET /applications/proof-app/commands timed out (timeout=1s, observed=1s). BASE: forward —... timed out (timeout=1s, observed=3600s)(a 1s timeout reported as an hour); backward —... was aborted (timeout=1s, observed=0s)(duration zeroed and timeout misclassified as abort). Receipts:/tmp/clock-proof/deploy-{head,base}-{fwd,bwd}.json.Observed result after fix: The shipped error text reports the real 1s duration and the correct timeout classification under ±1h wall-clock steps; base reports an hour (or zero) and flips the classification.
What was not tested: The live Discord REST API, real command registration outcomes, and OS/NTP clock adjustment. Timeout length and annotation field names are unchanged.
Intentionally out of scope