Skip to content

fix(telegram): bound stalled diagnostic response reads - #106035

Merged
steipete merged 13 commits into
openclaw:mainfrom
Alix-007:alix/telegram-diagnostic-response-read-timeouts
Jul 14, 2026
Merged

steipete merged 13 commits into
openclaw:mainfrom
Alix-007:alix/telegram-diagnostic-response-read-timeouts

Conversation

@Alix-007

@Alix-007 Alix-007 commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where Telegram diagnostics and membership audits could keep waiting after the Bot API returned response headers but then stalled or only trickled the response body.

Why This Change Was Made

Telegram Bot API diagnostic body reads now use a Telegram-local bounded reader with the existing byte cap, a per-chunk idle timeout, and an overall body deadline. The change covers getMe, best-effort getWebhookInfo, and membership-audit getChatMember reads without changing fetch/header timeout or webhook best-effort semantics.

User Impact

Telegram setup checks and membership audits now fail or degrade on a bounded deadline instead of appearing to spin forever on a stuck response body.

Evidence

  • node scripts/run-vitest.mjs extensions/telegram/src/response-body-timeout.test.ts extensions/telegram/src/probe.response-body-timeout.test.ts extensions/telegram/src/probe.test.ts extensions/telegram/src/audit.test.ts (22 tests passed)
  • git diff --check upstream/main..HEAD
  • Claude autoreview: clean, no accepted/actionable findings

Exact-head controlled-network proof

Exact head: f174acb7b443a366fed7048448884d226dab886f.

Command:

HTTP_PROXY= HTTPS_PROXY= http_proxy= https_proxy= ALL_PROXY= all_proxy= NO_PROXY=127.0.0.1,localhost no_proxy=127.0.0.1,localhost node_modules/.bin/tsx scratchpad/telegram-diagnostic-exact-head-proof.mts

The temporary harness was removed after the run. It called production probeTelegram() and auditTelegramGroupMembership() through the production Telegram undici transport, routing only the Bot API root to a loopback node:http server. It used a redacted fake token, no mocked adapter, no real Telegram traffic, and no credentials.

Redacted transcript:

proof: exact-head production Telegram diagnostics against local Bot API
exact-head: f174acb7b443a366fed7048448884d226dab886f
apiRoot: http://127.0.0.1:<redacted-port>
server: accepted getMe mode=header-stall
[fetch-timeout] fetch timeout after 295ms (elapsed 296ms) operation=fetchWithTimeout url=http://127.0.0.1:<redacted-port>/bot***/getMe
probe: mode=header-stall ok=false error=request timed out webhook=none elapsed=360ms
server: client closed getMe
server: accepted getMe mode=body-stall
probe: mode=body-stall ok=false error=Telegram diagnostic response body stalled for 139ms webhook=none elapsed=168ms
server: client closed getMe
server: accepted getMe mode=trickle
probe: mode=trickle ok=false error=Telegram diagnostic response body timed out after 295ms webhook=none elapsed=302ms
server: client closed getMe
server: accepted getMe mode=normal
probe: mode=normal ok=true error=none webhook=none elapsed=6ms
server: accepted getMe mode=webhook-body-stall
server: accepted getWebhookInfo mode=webhook-body-stall
probe: mode=webhook-body-stall ok=true error=none webhook=none elapsed=156ms
server: client closed getWebhookInfo
server: accepted getChatMember mode=audit-body-stall
audit: mode=audit-body-stall ok=false error=Telegram membership audit response body stalled for 150ms elapsed=179ms
server: client closed getChatMember
server: accepted getChatMember mode=audit-normal
audit: mode=audit-normal ok=true status=member elapsed=6ms
server: aborted-response-count=5

Observed: header, partial-body, and slow-trickle failures return within the harness budget and close their sockets; a later normal diagnostic succeeds; webhook body failure remains best-effort; membership audit fails boundedly and then recovers on a normal response. All assertions passed; exit 0.

Known limits: this is controlled local Bot API transport proof, not live Telegram. The 300 ms caller budget is for the proof harness and is not the production default. The exact command referenced a temporary uncommitted harness that has been removed.

Current-head CI follow-up

Current merge head after the ordinary GitHub update-branch: 60fa08969d9b011d0996572770d4992eeea4d0ff. Contributor fix commit: dd69ccd53f046e6ee6472fe5576b48a15646fd87.

Secretless GitHub CI: https://github.com/openclaw/openclaw/actions/runs/29244735197

  • check-test-types: passed; the earlier TS2493 in extensions/telegram/src/response-body-timeout.test.ts is fixed by typing the cancellation mock's optional reason argument.
  • check-prod-types, check-additional-extension-bundled, checks-node-compact-small-2, and all Node test shards: passed.
  • 59 checks passed overall; no checks remain pending.
  • check-lint still fails only in src/gateway/server-lanes.ts and src/agents/session-suspension.ts, both inherited from the merged main snapshot and outside this PR's Telegram diff.
  • check-dependencies still fails on the inherited stale dead-export baseline entry src/config/sessions/types.ts: QuotaSuspension, outside this PR's Telegram diff.

Known limits: the controlled local Bot API proof above was run at f174acb7b443a366fed7048448884d226dab886f and is not presented as a live Telegram run or as rerun at this merge head. The contributor follow-up changes only test mock typing; no credentialed local/Testbox execution was used.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: M labels Jul 13, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 13, 2026
@clawsweeper

clawsweeper Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 14, 2026, 6:30 AM ET / 10:30 UTC.

Summary
The PR adds Telegram-local byte-limited response-body reads with idle and overall deadlines for getMe, best-effort getWebhookInfo, and membership-audit getChatMember, plus cancellation and timeout coverage.

PR surface: Source +194, Tests +264. Total +458 across 6 files.

Reproducibility: yes. at source level: current code can finish fetchWithTimeout when headers arrive and then wait indefinitely while the size-limited reader awaits a stalled body. The review did not run a failing current-main Telegram request.

Review metrics: 1 noteworthy metric.

  • Bounded response readers: 3 call sites changed. The patch covers both diagnostic Bot API reads and the membership-audit read without adding configuration, defaults, migrations, or public SDK surface.

Stored data model
Persistent data-model change detected: serialized state: extensions/telegram/src/audit.test.ts, serialized state: extensions/telegram/src/probe.response-body-timeout.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦐 gold shrimp
Patch quality: 🦞 diamond lobster
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add a redacted exact-head live Telegram smoke for successful probe and membership-audit paths.
  • Update the PR body with the proof so ClawSweeper reruns, or ask a maintainer for @clawsweeper re-review.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The controlled production-path loopback transcript is strong supplemental proof, but this Telegram transport PR still needs a redacted exact-head live Telegram smoke; update the PR body afterward to trigger review, or ask a maintainer to comment @clawsweeper re-review.

Risk before merge

  • [P2] The controlled loopback transcript proves pathological stalled-body handling, but it predates the current head and does not show a normal exact-head request against Telegram's real Bot API; a false timeout or transport regression in ordinary getMe, webhook, or membership-audit traffic therefore remains unproven.

Maintainer options:

  1. Decide the mitigation before merge
    Keep the Telegram-local bounded reader, then add a redacted exact-head live Telegram smoke showing successful getMe, best-effort webhook inspection, and configured-group membership audit alongside the existing deterministic stalled-server transcript.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] No automated code repair is identified; the remaining merge gate is contributor-supplied exact-head live Telegram proof followed by ordinary Telegram-area review.

Security
Cleared: The patch reduces denial-of-service exposure from stalled or oversized Telegram responses and does not alter dependencies, workflows, secrets, permissions, package resolution, or public API surfaces.

Review details

Best possible solution:

Keep the Telegram-local bounded reader, then add a redacted exact-head live Telegram smoke showing successful getMe, best-effort webhook inspection, and configured-group membership audit alongside the existing deterministic stalled-server transcript.

Do we have a high-confidence way to reproduce the issue?

Yes at source level: current code can finish fetchWithTimeout when headers arrive and then wait indefinitely while the size-limited reader awaits a stalled body. The review did not run a failing current-main Telegram request.

Is this the best way to solve the issue?

Yes for the implementation shape: a Telegram-private helper preserves the existing byte limit and caller semantics without expanding core or Plugin SDK contracts. Merge readiness remains incomplete until the required live Telegram smoke is supplied.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 20f145f9c1ab.

Label changes

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦞 diamond lobster.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The controlled production-path loopback transcript is strong supplemental proof, but this Telegram transport PR still needs a redacted exact-head live Telegram smoke; update the PR body afterward to trigger review, or ask a maintainer to comment @clawsweeper re-review.
  • remove proof: sufficient: Current real behavior proof status is insufficient, not sufficient.
  • remove rating: 🦞 diamond lobster: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: 📣 needs proof.

Label justifications:

  • P2: This is a normal-priority Telegram reliability fix for diagnostics and audits with a limited channel-local blast radius.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦞 diamond lobster.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The controlled production-path loopback transcript is strong supplemental proof, but this Telegram transport PR still needs a redacted exact-head live Telegram smoke; update the PR body afterward to trigger review, or ask a maintainer to comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +194, Tests +264. Total +458 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 201 7 +194
Tests 3 264 0 +264
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 465 7 +458

What I checked:

  • Current behavior remains vulnerable to stalled bodies: The target main implementation bounds fetch/header waiting and response size, but its subsequent response-body read has no idle or overall body deadline, so a server that sends headers and then stalls can leave diagnostics pending. (extensions/telegram/src/probe.ts:193, 20f145f9c1ab)
  • Focused owner-boundary implementation: The PR introduces a Telegram-private reader that retains the existing byte cap, races stream reads against idle and overall deadlines, and cancels the response body on failure without expanding the Plugin SDK surface. (extensions/telegram/src/response-body-timeout.ts:1, 5550d0ee733c)
  • Diagnostic callers use remaining budget: The getMe and best-effort webhook body reads are routed through the bounded reader while preserving the probe's existing total budget and webhook degradation semantics. (extensions/telegram/src/probe.ts:121, 5550d0ee733c)
  • Membership audit is covered: The getChatMember audit path now bounds body consumption and returns a Telegram-specific stalled or deadline error instead of waiting indefinitely. (extensions/telegram/src/audit-membership-runtime.ts:18, 5550d0ee733c)
  • Regression coverage exercises cancellation: Added tests cover streamed body stalls, trickling bodies, byte overflow, deadline fallback, cancellation, normal responses, webhook best-effort behavior, and audit failure reporting. (extensions/telegram/src/probe.response-body-timeout.test.ts:1, 5550d0ee733c)
  • Controlled production-path proof: The PR body records an exact-head loopback Bot API run through production probe and audit entry points: header stalls, body stalls, and trickles completed within bounded budgets, sockets closed, normal requests recovered, and webhook failure remained best-effort. (extensions/telegram/src/probe.ts:204, f174acb7b443)

Likely related people:

  • obviyus: Recent merged history covers Telegram transport fallback, polling liveness, and recovery behavior adjacent to the fetch and response lifecycle changed here. (role: recent Telegram transport contributor; confidence: high; commits: 1b38f80088c7, 56873b606578; files: extensions/telegram/src/fetch.ts, extensions/telegram/src/polling-session.ts, extensions/telegram/src/polling-liveness.ts)
  • stainlu: Introduced the Telegram startup probe limiter and touched the channel probe entry point that calls the changed diagnostic path. (role: recent Telegram startup contributor; confidence: medium; commits: f1381b5312fb; files: extensions/telegram/src/startup-probe-limiter.ts, extensions/telegram/src/channel.ts, extensions/telegram/src/channel.gateway.test.ts)
  • Alix-007: Beyond proposing this PR, prior merged history applied the same shared bounded-response helper family to self-hosted provider discovery reads, making this contributor relevant to the response-limit design. (role: adjacent bounded-response contributor; confidence: medium; commits: 2592f8a51a4e; files: src/agents/provider-http-errors.ts, src/agents/provider-http-errors.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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 keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (5 earlier review cycles)
  • reviewed 2026-07-13T05:24:09.460Z sha f174acb :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-13T06:31:41.918Z sha f174acb :: needs maintainer review before merge. :: none
  • reviewed 2026-07-13T11:28:26.876Z sha 60fa089 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-13T16:12:26.002Z sha 92cea87 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T02:20:03.137Z sha 24cb4e5 :: needs maintainer review before merge. :: none

@Alix-007

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 13, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 13, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 13, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 14, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 14, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: L and removed size: M labels Jul 14, 2026
# Conflicts:
#	CHANGELOG.md
#	docs/.generated/plugin-sdk-api-baseline.sha256
@steipete

steipete commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Land-ready at e2e385648e1.

Maintainer work:

  • Replaced the Telegram-local response reader with the shared bounded HTTP body reader.
  • Added an overall deadline alongside the existing byte cap and idle timeout, with stream cancellation on either timeout.
  • Applied one total timeout budget across sequential membership checks.
  • Added shared-reader regressions plus real-socket coverage using the production Telegram transport and Undici; stalled and continuously trickling bodies both terminate and close their sockets.
  • Updated the plugin SDK surface docs/baseline. Release-note context remains in the PR body because root changelog entries are release-owned.

Runtime-head proof at 5b5b9ba326d on Blacksmith Testbox tbx_01kxgjb9y2dspjt7m6yzzcaa06 (Actions run). Final head e2e385648e1 differs only by removing the release-owned root changelog entry:

  • corepack pnpm test src/infra/http-body.response.test.ts extensions/telegram/src/probe.response-body-timeout.test.ts extensions/telegram/src/probe.response-body-timeout.integration.test.ts extensions/telegram/src/probe.test.ts extensions/telegram/src/audit.test.ts — 44/44 passed.
  • corepack pnpm plugin-sdk:api:check — passed.
  • corepack pnpm plugin-sdk:surface:check — passed.
  • Full corepack pnpm build — passed.
  • corepack pnpm check:changed — passed, including format, full core/plugin lint, core/test/plugin typechecks, SDK/API boundaries, import-cycle, database-first, runtime-loader, and other repository guards.
  • Fresh post-merge autoreview thread 019f6126-549d-7982-a866-a1487d2f94c9 — clean at 0.94 confidence; no accepted/actionable findings.
  • git diff --check — passed.

Proof gap: the documented openclaw-telegram-user-crabbox-proof wrapper is not installed and no project-local replacement exists, so I could not run an authenticated real-user Telegram roundtrip from this checkout. The exact maintainer head does have real HTTP socket/production transport coverage; this PR also has a successful same-PR Real behavior proof workflow and full green CI run 29308171537 from today.

@steipete
steipete merged commit 111f7cd into openclaw:main Jul 14, 2026
100 of 101 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 15, 2026
* fix(telegram): bound stalled diagnostic response reads

* test(telegram): type timeout cancellation mock

* style(telegram): apply oxfmt to diagnostic response timeout files

* fix(telegram): share diagnostic body deadlines

Co-authored-by: Alix-007 <[email protected]>

* chore: leave release notes release-owned

---------

Co-authored-by: Peter Steinberger <[email protected]>
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
* fix(telegram): bound stalled diagnostic response reads

* test(telegram): type timeout cancellation mock

* style(telegram): apply oxfmt to diagnostic response timeout files

* fix(telegram): share diagnostic body deadlines

Co-authored-by: Alix-007 <[email protected]>

* chore: leave release notes release-owned

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants