Repository navigation
fix(telegram): limit startup getMe fanout - #80986
Conversation
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: no. for a high-confidence live reproduction in this review. Source inspection shows the current Gateway limiter releases before the Telegram Real behavior proof Next step before merge Security Review detailsBest 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 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:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against f506ced2b3a6. |
08eb0fb to
ebddfa5
Compare
ebddfa5 to
74796f3
Compare
35ddbd5 to
2d389e1
Compare
|
Landing with maintainer override after rebasing onto current Verification run locally on the repaired PR branch:
GitHub checks for
Known gap: Thanks @stainlu. |
|
Landed via squash merge onto
Thanks @stainlu. |
## 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]>
## 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]>
## 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]>
## 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]>
"## Summary\n\n- Problem: multi-account Telegram gateway startup can still fan out several
getMeprobes at once. The generic Gateway startup worker limit only throttles account task handoff; it does not hold a slot while the long-lived TelegramstartAccountpromise performs its startup probe.\n- Why it matters: #80695 reports Windows startup event-loop starvation with many Telegram accounts, including multiplegetMetimeouts duringchannels.telegram.start-account.\n- What changed: Telegram now limits concurrent startupgetMeprobes 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 twoprobeTelegramcalls 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-livedstartAccountwork is handed off to a tracked promise immediately. The TelegramgetMestartup 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: TelegramstartAccountperforms 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 gatewaystartAccountboundary 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"