Repository navigation
Conversation
auditTelegramGroupMembershipImpl seeded its fetch/read deadline with Date.now() and computed remaining budget with Date.now() too, while fetchWithTimeout and readResponseWithLimit consume that budget through monotonic setTimeout timers. A wall-clock jump (NTP resync or manual adjustment) distorted the remaining budget: a forward jump shrank it to zero, misreporting a healthy audit as timed out; a backward jump inflated it, amplifying the timeout and stalling the audit past its configured budget. Seed the deadline and derive remaining budget from performance.now() instead so both sides measure elapsed time on the same monotonic clock.
|
🦞👀 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 changesThis PR uses monotonic time to calculate Telegram membership-audit deadlines and adds regression coverage for wall-clock jumps. Example: The host clock advances 60 seconds during a healthy Telegram group membership audit.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current Telegram audit deadline bug with a focused change; no actionable findings remain, and the exact-head CI gate passes. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Telegram plugin receives configured group IDs and an audit budget from channel status checks, queries the Bot API, and returns membership results and diagnostic errors. flowchart LR
A[Channels status CLI] --> B[Gateway channels status]
B --> C[Telegram account audit]
C --> D[Membership deadline owner]
D --> E[Fetch and bounded body reader]
E --> F[Telegram Bot API]
E --> G[Membership audit result]
Technical reviewBest possible solution: Merge the focused monotonic-clock repair while retaining the existing shared timeout budget and transport lifecycle. Do we have a high-confidence way to reproduce the issue? Current-main source directly exposes the clock mismatch, and the contributor supplies before/after CLI and Gateway output for both jump directions; this read-only review did not execute target code. Is this the best way to solve the issue? Using performance.now() for the local deadline and every remaining-budget read restores the existing timeout invariant without another abstraction or configuration option. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 32d0945d21d2. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource 0, Tests +44. Total +44 across 2 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 (3 earlier review cycles)
Reviewed October 27, 2026, 1:43 AM ET / 05:43 UTC (Revision 4). |
The initial regression test responded immediately, so the audit completed before the wall-clock jump mattered and passed even with the Date.now() deadline. Hold group 1's fetch across the jump so the shared deadline is re-read afterward, and hold group 2's response body idle so the audit is bounded only by the recomputed remaining budget. Verified both directions: green on performance.now() (head), red on Date.now() (base) - a forward jump clamps the budget to ~1ms (request never completes) and a backward jump inflates it (never settles within the window).
|
🦞👀 Re-review progress:
|
|
🦞👀 Re-review progress:
|
|
🦞👀 Re-review progress:
|
|
Runtime proof on head 57803a8 against main 9b7db69: built CLI and Gateway in a secretless Node 24.22.1 container, running the shipped
Limits: main's existing monotonic outer budget caps it near 6 seconds, so this doesn't show a full 60-second stall. The reported |
|
Landed in 25fc14d. Thanks @SunnyShu0925. The Telegram membership audit now ignores wall-clock jumps. |
|
@obviyus Thanks! |
…penclaw#185290) fix(telegram): keep the membership audit deadline on the monotonic clock The Telegram membership audit measured its deadline with the wall clock, so a backward clock step let it overrun its budget, and `channels status --probe` lost the audit detail to the outer status timeout. The deadline now uses monotonic time. Evidence: shipped `openclaw channels status --probe` through the real Gateway and Telegram adapter to a local Bot API fixture, with Date.now shifted back 60 seconds inside the Gateway process only. On main the status came back partial or config-only after 6.8s and 7.4s (twice); with this change it returned the full audit in 4.3s and 4.4s (twice), matching the no-step runs. The reported audit.elapsedMs still uses the wall clock and is not fixed here. Production 6 lines. Thanks @SunnyShu0925. Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: Ayaan Zaidi <[email protected]>
…185290) fix(telegram): keep the membership audit deadline on the monotonic clock The Telegram membership audit measured its deadline with the wall clock, so a backward clock step let it overrun its budget, and `channels status --probe` lost the audit detail to the outer status timeout. The deadline now uses monotonic time. Evidence: shipped `openclaw channels status --probe` through the real Gateway and Telegram adapter to a local Bot API fixture, with Date.now shifted back 60 seconds inside the Gateway process only. On main the status came back partial or config-only after 6.8s and 7.4s (twice); with this change it returned the full audit in 4.3s and 4.4s (twice), matching the no-step runs. The reported audit.elapsedMs still uses the wall clock and is not fixed here. Production 6 lines. Thanks @SunnyShu0925. Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 25fc14d) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 58a49bb31d7a50f82398f5c898d761f3ea79bacd)
What Problem This Solves
A Telegram group membership audit that runs while the host clock jumps (NTP resync, manual change) can report a healthy audit as timed out, or stall past its budget. The audit deadline and its remaining budget came from
Date.now()(wall clock), while the fetch and response-body timeouts consume that budget through monotonicsetTimeouttimers, so a clock jump distorts the remaining budget in either direction.auditTelegramGroupMembershipImplseededdeadlineMswithDate.now()and recomputed the remaining budget withDate.now()before eachfetchWithTimeout/readResponseWithLimitcall. A forward jump clamps the budget to zero and fast-paths a healthy audit to "timed out" without making a request; a backward jump inflates it and stalls the audit.performance.now(), matching the monotonic timers. The deadline is a process-internal closure, never serialized or read across processes, so no dual-clock handling is needed.Date.now()calls inextensions/telegram/src/audit-membership-runtime.ts. TheelapsedMsreport inaudit.tsstays on the wall clock; no API or transport behavior changes.Why This Change Was Made
The audit runs inside the Gateway and must not hang or fail because of clock adjustments. Since the deadline is produced and consumed locally within one audit call, the monotonic clock is the only correct reference for it.
User Impact
Telegram group audits now finish within their configured timeout regardless of host clock adjustments. Operators no longer see spurious "timed out" results or audits that stall past their budget after a clock resync.
Evidence
Shipped path: the real CLI (
openclaw channels status --probe --timeout 70000) → Gateway WebSocket RPC →channels.status→ TelegramauditAccount→auditTelegramGroupMembershipImpl→ realfetchto a real loopback Bot API HTTP peer. A probe in the Gateway process answers the audit's secondDate.now()(the remaining-budget read) as real ± 60000ms, modelling an NTP jump between the deadline seed and that read. Both runs use the checkout's built CLI and Gateway; pre-fix is the origin/main bundle, post-fix is the same bundle with this PR's compiled three-line change (that file is the only source delta).Date.now())performance.now())audit okaudit okaudit failed— "timed out after 29993ms",elapsedMs: 2, nogetChatMemberaudit ok—status: "member",elapsedMs: 5,getChatMembersenttelegram status timed out after 30000ms(CLI 35.3s): the inflated budget outlived the status budgetBoth backward runs report failure because the peer stalls the body; the difference is the bound: 30s status timeout versus a 14.99s audit bound.
Raw terminal output:
Gateway clock probe, pre-fix:
audit #1 Date.now() #1 (deadline seed)ataudit-membership-runtime-DOlhcNn8.mjs:23:27, then#2 (remaining-budget read) answered as real+60000msat:34:59; the backward run answersreal-60000msat:34:59and:42:57. Post-fix: noaudit Date.now()line is ever emitted; the log only recordsarm file observed.Bot API peer: pre-fix +60s run has
getMeat05:21:20.658Z, next poll at05:21:24.511Z, nogetChatMemberin between; post-fix +60s run hasgetMe05:23:04.497Z→getChatMember ?chat_id=-1001&user_id=70000000105:23:04.507Z.Regression test (
audit.test.ts,it.each([-60_000, 60_000]), fake timers move onlyDate.now()): holds group 1's fetch across the jump so the shared deadline is re-read, and holds group 2's response body idle; pre-fix RED in both directions, post-fix GREEN 9/9.