Skip to content

fix(telegram): limit startup getMe fanout - #80986

Merged
steipete merged 2 commits into
openclaw:mainfrom
stainlu:fix/telegram-start-account-concurrency
May 13, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
stainlu:fix/telegram-start-account-concurrency

Conversation

@stainlu

@stainlu stainlu commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

"## Summary\n\n- Problem: multi-account Telegram gateway startup can still fan out several getMe probes at once. The generic Gateway startup worker limit only throttles account task handoff; it does not hold a slot while the long-lived Telegram startAccount promise performs its startup probe.\n- Why it matters: #80695 reports Windows startup event-loop starvation with many Telegram accounts, including multiple getMe timeouts during channels.telegram.start-account.\n- What changed: Telegram now limits concurrent startup getMe probes to 2 across accounts, releases the slot before entering the long-running monitor, and treats abort while queued as cancellation instead of falling through to monitor startup.\n- What did NOT change: polling sink concurrency, message delivery concurrency, polling lease behavior, and Telegram runtime config shape are unchanged.\n\n## Coordination Note\n\n- This intentionally takes the narrow Telegram-local path. It overlaps with #78437, which changes broader Gateway startup staggering and prewarm ordering and has live Windows multi-bot proof.\n- If maintainers prefer the broader Gateway-level direction from #78437, this PR can stand down or be retargeted. If the narrower owner-local fix is preferred, this PR needs live/redacted multi-account Telegram startup proof before merge.\n\n## Change Type\n\n- [x] Bug fix\n- [ ] Feature\n- [ ] Refactor required for the fix\n- [x] Docs\n- [ ] Security hardening\n- [ ] Chore/infra\n\n## Scope\n\n- [ ] Gateway / orchestration\n- [ ] Skills / tool execution\n- [ ] Auth / tokens\n- [ ] Memory / storage\n- [x] Integrations\n- [ ] API / contracts\n- [ ] UI / DX\n- [ ] CI/CD / infra\n\n## Linked Issue/PR\n\n- Refs #80695\n- Related: #78437\n- [x] This PR fixes a bug or regression\n\n## Real behavior proof\n\n- Behavior addressed: Telegram account startup probes are now bounded even when several accounts start together.\n- Real environment tested: local OpenClaw checkout on macOS, running the actual Telegram channel gateway startup handler with OpenClaw's channel test context and a controlled Telegram runtime.\n- Exact steps or command run after this patch:\n\ntext\nenv OPENCLAW_TEST_HEAVY_CHECK_LOCK_HELD=1 OPENCLAW_VITEST_MAX_WORKERS=1 pnpm --config.manage-package-manager-versions=false test extensions/telegram/src/channel.gateway.test.ts src/gateway/server-channels.test.ts\n\n\n- Evidence after fix:\n\ntext\nTest Files 1 passed (1)\nTests 31 passed (31)\n\nTest Files 1 passed (1)\nTests 10 passed (10)\n\n[test] passed 2 Vitest shards in 15.74s\n\n\n- Observed result after fix: the new Telegram gateway regression launches three accounts concurrently, observes only two probeTelegram calls running until one slot releases, then verifies the queued third account starts and all three monitors run. A second regression aborts a queued third account and verifies the queued account exits as cancellation without starting a third probe or monitor.\n- What was not tested: live Windows 8-account Telegram startup with real Bot API credentials. This PR intentionally fixes the deterministic startup probe fanout piece from #80695 and does not claim to close the full transport/outbound cascade umbrella.\n\n## Root Cause\n\n- Root cause: the Gateway's generic account startup concurrency limit bounds account task setup, but Telegram's long-lived startAccount work is handed off to a tracked promise immediately. The Telegram getMe startup probe runs inside that long-lived promise, so several account probes can still overlap.\n- Missing detection / guardrail: existing Telegram gateway startup tests covered probe timeout, botInfo handoff, and unauthorized-token behavior, but not multi-account probe fanout or abort while queued behind startup work.\n- Contributing context: Telegram startAccount performs a visible Bot API control-plane probe before entering the long-running monitor; this is exactly the phase reported timing out in #80695.\n\n## Regression Test Plan\n\n- Coverage level that should have caught this:\n - [x] Unit test\n - [x] Seam / integration test\n - [ ] End-to-end test\n - [ ] Existing coverage already sufficient\n- Target test or file: extensions/telegram/src/channel.gateway.test.ts\n- Scenario the test should lock in: no more than two Telegram startup probes run concurrently across accounts, and an account aborted while queued does not continue into probe or monitor startup.\n- Why this is the smallest reliable guardrail: it exercises the Telegram plugin gateway startAccount boundary directly without requiring live Bot API credentials or a full Gateway process.\n- Existing test that already covers this: none.\n\n## User-visible / Behavior Changes\n\nLarge Telegram multi-account configs start account probes in a small bounded pool instead of probing every account at once.\n\n## Security Impact\n\n- New permissions/capabilities? No\n- Secrets/tokens handling changed? No\n- New/changed network calls? No\n- Command/tool execution surface changed? No\n- Data access scope changed? No\n\n## Human Verification\n\n- Verified scenarios: bounded startup probes, queued-start cancellation, existing unauthorized-token startup rejection, startup timeout propagation, botInfo handoff, and Gateway channel manager startup tests.\n- Edge cases checked: queued account abort before slot acquisition; slot release before monitor startup so the long-running monitor does not hold the limiter forever.\n- What you did not verify: live Telegram Bot API startup under the reporter's Windows 8-account setup.\n\n## Validation\n\n- pnpm exec oxfmt --check --threads=1 CHANGELOG.md docs/channels/telegram.md extensions/telegram/src/channel.ts extensions/telegram/src/channel.gateway.test.ts extensions/telegram/src/startup-probe-limiter.ts\n- node scripts/format-docs.mjs --check docs/channels/telegram.md\n- git diff --check\n- env OPENCLAW_TEST_HEAVY_CHECK_LOCK_HELD=1 OPENCLAW_VITEST_MAX_WORKERS=1 pnpm --config.manage-package-manager-versions=false test extensions/telegram/src/channel.gateway.test.ts src/gateway/server-channels.test.ts\n- env OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD=1 pnpm --config.manage-package-manager-versions=false run tsgo:extensions\n- env OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD=1 pnpm --config.manage-package-manager-versions=false run tsgo:extensions:test\n\n## Compatibility / Migration\n\n- Backward compatible? Yes\n- Config/env changes? No\n- Migration needed? No\n"

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: telegram Channel integration: telegram size: M triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 12, 2026
@clawsweeper

clawsweeper Bot commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Summary
Adds a Telegram-local two-slot startup getMe probe limiter, abort-aware queue handling, regression tests, docs, and a changelog entry.

Reproducibility: no. for a high-confidence live reproduction in this review. Source inspection shows the current Gateway limiter releases before the Telegram getMe probe finishes, and the linked Windows report provides real timeout/starvation logs.

Real behavior proof
Needs real behavior proof before merge: The PR body shows controlled-runtime Vitest output, but not after-fix live or equivalent real multi-account Telegram Bot API startup proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, ask a maintainer to comment @clawsweeper re-review.

Next step before merge
Contributor and maintainer action is needed for redacted real Telegram startup proof and scope choice with the overlapping gateway startup PR; this is not a safe repair-job handoff.

Security
Cleared: The diff only changes Telegram startup scheduling, tests, docs, and changelog text; it does not add dependencies, workflows, secret handling, package resolution, or command execution.

Review details

Best possible solution:

Land either this narrow Telegram-local limiter or the broader gateway startup staggering after maintainers choose the scope and live multi-account Telegram startup proof shows bounded probes without regressions.

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

No for a high-confidence live reproduction in this review. Source inspection shows the current Gateway limiter releases before the Telegram getMe probe finishes, and the linked Windows report provides real timeout/starvation logs.

Is this the best way to solve the issue?

Unclear as the final merge path. A Telegram-local two-slot limiter is a narrow owner-local repair, but maintainers should reconcile it with #78437 and require real Telegram proof before merge.

What I checked:

Likely related people:

  • @steipete: Recent history on the same Gateway channel startup and Telegram startup/probe surfaces includes the channel startup fanout cap and multiple Telegram startup/probe fixes. (role: recent adjacent startup contributor; confidence: high; commits: bf2711b40ef7, b5e7857c4b33, d7c3a77b938d; files: src/gateway/server-channels.ts, extensions/telegram/src/channel.ts, extensions/telegram/src/probe.ts)
  • @obviyus: Recent merged Telegram work changed startup probe reuse and outbound delivery behavior on the same channel/probe surface. (role: recent Telegram startup contributor; confidence: medium; commits: 5b94c4ce9396, 6554e85ad6e9; files: extensions/telegram/src/channel.ts, extensions/telegram/src/probe.ts)
  • @shakkernerd: Recent commits tightened Telegram gateway probe and warning assertions in the same test area this PR extends. (role: recent Telegram test contributor; confidence: medium; commits: 006a3778ebf7, 9a1de1c4cabb; files: extensions/telegram/src/channel.gateway.test.ts)
  • @gumadeiras: Prior channel status and native approval lifecycle work touches adjacent startup/status mechanics used by channel startup. (role: adjacent channel lifecycle contributor; confidence: low; commits: 24db09a19bde, d78512b09d1d; files: extensions/telegram/src/channel.ts, src/gateway/server-channels.ts)

Remaining risk / open question:

  • No redacted live multi-account Telegram Bot API startup proof has been supplied for the after-fix behavior.
  • The narrow Telegram-local limiter overlaps with the broader open gateway startup-staggering PR, so maintainers need to choose the preferred scope.

Codex review notes: model gpt-5.5, reasoning high; reviewed against f506ced2b3a6.

@stainlu
stainlu force-pushed the fix/telegram-start-account-concurrency branch 4 times, most recently from 08eb0fb to ebddfa5 Compare May 12, 2026 11:28
@steipete
steipete force-pushed the fix/telegram-start-account-concurrency branch from ebddfa5 to 74796f3 Compare May 13, 2026 13:00
@steipete steipete added proof: override Maintainer override for the external PR real behavior proof gate. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 13, 2026
@steipete
steipete force-pushed the fix/telegram-start-account-concurrency branch from 35ddbd5 to 2d389e1 Compare May 13, 2026 13:16
@steipete

Copy link
Copy Markdown
Contributor

Landing with maintainer override after rebasing onto current origin/main.

Verification run locally on the repaired PR branch:

  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md docs/channels/telegram.md extensions/telegram/src/channel.ts extensions/telegram/src/channel.gateway.test.ts extensions/telegram/src/startup-probe-limiter.ts
  • node scripts/format-docs.mjs --check docs/channels/telegram.md
  • git diff --check HEAD~1..HEAD
  • env OPENCLAW_TEST_HEAVY_CHECK_LOCK_HELD=1 OPENCLAW_VITEST_MAX_WORKERS=1 pnpm --config.manage-package-manager-versions=false test extensions/telegram/src/channel.gateway.test.ts src/gateway/server-channels.test.ts
  • env OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD=1 pnpm --config.manage-package-manager-versions=false run tsgo:extensions
  • env OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD=1 pnpm --config.manage-package-manager-versions=false run tsgo:extensions:test
  • git diff --check origin/main...HEAD

GitHub checks for 2d389e1010742efa884eacea520afd588d0b898f:

Known gap: check-test-types is red in src/auto-reply/reply/queue/settings.test.ts, outside this PR's diff (CHANGELOG.md, docs/channels/telegram.md, extensions/telegram/src/channel.gateway.test.ts, extensions/telegram/src/channel.ts, extensions/telegram/src/startup-probe-limiter.ts). The failing file is not touched by this PR, and the PR-specific Telegram tests/type lanes passed locally.

Thanks @stainlu.

@steipete
steipete merged commit f1381b5 into openclaw:main May 13, 2026
103 of 105 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Landed via squash merge onto main.

  • PR head before merge: 2d389e1010742efa884eacea520afd588d0b898f
  • Merge commit: f1381b5
  • Local proof: formatting/docs, focused Telegram/gateway Vitest, tsgo:extensions, tsgo:extensions:test, and git diff --check as listed above.
  • CI: proof, OpenGrep, Workflow Sanity, CodeQL Critical Quality, and all PR-related CI lanes green except unrelated check-test-types in src/auto-reply/reply/queue/settings.test.ts.

Thanks @stainlu.

l3ocifer pushed a commit to l3ocifer/frack-openclaw that referenced this pull request May 13, 2026
## Summary

- Limit Telegram startup `getMe` probes to two concurrent accounts.
- Add regression coverage for queued startup and queued abort behavior.
- Document the multi-account startup bound and add changelog credit.

## Verification

- `pnpm exec oxfmt --check --threads=1 CHANGELOG.md docs/channels/telegram.md extensions/telegram/src/channel.ts extensions/telegram/src/channel.gateway.test.ts extensions/telegram/src/startup-probe-limiter.ts`
- `node scripts/format-docs.mjs --check docs/channels/telegram.md`
- `git diff --check HEAD~1..HEAD`
- `env OPENCLAW_TEST_HEAVY_CHECK_LOCK_HELD=1 OPENCLAW_VITEST_MAX_WORKERS=1 pnpm --config.manage-package-manager-versions=false test extensions/telegram/src/channel.gateway.test.ts src/gateway/server-channels.test.ts`
- `env OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD=1 pnpm --config.manage-package-manager-versions=false run tsgo:extensions`
- `env OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD=1 pnpm --config.manage-package-manager-versions=false run tsgo:extensions:test`
- GitHub CI mostly green on `2d389e1010742efa884eacea520afd588d0b898f`; `check-test-types` red in unrelated `src/auto-reply/reply/queue/settings.test.ts` outside this PR's diff.

Co-authored-by: stainlu <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
## Summary

- Limit Telegram startup `getMe` probes to two concurrent accounts.
- Add regression coverage for queued startup and queued abort behavior.
- Document the multi-account startup bound and add changelog credit.

## Verification

- `pnpm exec oxfmt --check --threads=1 CHANGELOG.md docs/channels/telegram.md extensions/telegram/src/channel.ts extensions/telegram/src/channel.gateway.test.ts extensions/telegram/src/startup-probe-limiter.ts`
- `node scripts/format-docs.mjs --check docs/channels/telegram.md`
- `git diff --check HEAD~1..HEAD`
- `env OPENCLAW_TEST_HEAVY_CHECK_LOCK_HELD=1 OPENCLAW_VITEST_MAX_WORKERS=1 pnpm --config.manage-package-manager-versions=false test extensions/telegram/src/channel.gateway.test.ts src/gateway/server-channels.test.ts`
- `env OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD=1 pnpm --config.manage-package-manager-versions=false run tsgo:extensions`
- `env OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD=1 pnpm --config.manage-package-manager-versions=false run tsgo:extensions:test`
- GitHub CI mostly green on `2d389e1010742efa884eacea520afd588d0b898f`; `check-test-types` red in unrelated `src/auto-reply/reply/queue/settings.test.ts` outside this PR's diff.

Co-authored-by: stainlu <[email protected]>
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
## Summary

- Limit Telegram startup `getMe` probes to two concurrent accounts.
- Add regression coverage for queued startup and queued abort behavior.
- Document the multi-account startup bound and add changelog credit.

## Verification

- `pnpm exec oxfmt --check --threads=1 CHANGELOG.md docs/channels/telegram.md extensions/telegram/src/channel.ts extensions/telegram/src/channel.gateway.test.ts extensions/telegram/src/startup-probe-limiter.ts`
- `node scripts/format-docs.mjs --check docs/channels/telegram.md`
- `git diff --check HEAD~1..HEAD`
- `env OPENCLAW_TEST_HEAVY_CHECK_LOCK_HELD=1 OPENCLAW_VITEST_MAX_WORKERS=1 pnpm --config.manage-package-manager-versions=false test extensions/telegram/src/channel.gateway.test.ts src/gateway/server-channels.test.ts`
- `env OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD=1 pnpm --config.manage-package-manager-versions=false run tsgo:extensions`
- `env OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD=1 pnpm --config.manage-package-manager-versions=false run tsgo:extensions:test`
- GitHub CI mostly green on `2d389e1010742efa884eacea520afd588d0b898f`; `check-test-types` red in unrelated `src/auto-reply/reply/queue/settings.test.ts` outside this PR's diff.

Co-authored-by: stainlu <[email protected]>
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
## Summary

- Limit Telegram startup `getMe` probes to two concurrent accounts.
- Add regression coverage for queued startup and queued abort behavior.
- Document the multi-account startup bound and add changelog credit.

## Verification

- `pnpm exec oxfmt --check --threads=1 CHANGELOG.md docs/channels/telegram.md extensions/telegram/src/channel.ts extensions/telegram/src/channel.gateway.test.ts extensions/telegram/src/startup-probe-limiter.ts`
- `node scripts/format-docs.mjs --check docs/channels/telegram.md`
- `git diff --check HEAD~1..HEAD`
- `env OPENCLAW_TEST_HEAVY_CHECK_LOCK_HELD=1 OPENCLAW_VITEST_MAX_WORKERS=1 pnpm --config.manage-package-manager-versions=false test extensions/telegram/src/channel.gateway.test.ts src/gateway/server-channels.test.ts`
- `env OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD=1 pnpm --config.manage-package-manager-versions=false run tsgo:extensions`
- `env OPENCLAW_TSGO_HEAVY_CHECK_LOCK_HELD=1 pnpm --config.manage-package-manager-versions=false run tsgo:extensions:test`
- GitHub CI mostly green on `2d389e1010742efa884eacea520afd588d0b898f`; `check-test-types` red in unrelated `src/auto-reply/reply/queue/settings.test.ts` outside this PR's diff.

Co-authored-by: stainlu <[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 proof: override Maintainer override for the external PR real behavior proof gate. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants