Skip to content

fix(telegram): disable HTTP/2 for all Telegram polling dispatchers - #69243

Closed
Magicray1217 wants to merge 1 commit into
openclaw:mainfrom
Magicray1217:fix/issue-66885-telegram-h2
Closed

Magicray1217 wants to merge 1 commit into
openclaw:mainfrom
Magicray1217:fix/issue-66885-telegram-h2

Conversation

@Magicray1217

Copy link
Copy Markdown
Contributor

Summary

Undici 8 enables HTTP/2 ALPN by default, causing Telegram long-polling connections to stall on Windows (IPv6 + H2 multiplexing issues).

The core fetch-guard (\src/infra/net/undici-runtime.ts) already applies \�llowH2: false\ for guarded paths, but the Telegram extension creates its own \Agent/\ProxyAgent/\EnvHttpProxyAgent\ instances directly from undici without this flag.

Changes

  • Apply \�llowH2: false\ to all dispatcher constructors in \�xtensions/telegram/src/fetch.ts\
  • Matches the approach used in \src/infra/net/undici-runtime.ts\ (\HTTP1_ONLY_DISPATCHER_OPTIONS)

Affected files

  • \�xtensions/telegram/src/fetch.ts\

Fixes #66885

Undici 8 enables HTTP/2 ALPN by default, but Telegram's long-polling
connections stall on Windows due to IPv6 + H2 multiplexing issues. The
core fetch-guard already sets allowH2:false for guarded paths, but the
Telegram extension creates its own Agent/ProxyAgent/EnvHttpProxyAgent
instances directly from undici without this flag.

Apply allowH2:false to all dispatcher constructors in the Telegram
transport layer, matching the approach used in src/infra/net/undici-runtime.ts.

Fixes openclaw#66885
@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: XS labels Apr 20, 2026
@greptile-apps

greptile-apps Bot commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Applies allowH2: false to all four Agent/ProxyAgent/EnvHttpProxyAgent construction paths inside createTelegramDispatcher, preventing Undici 8's default HTTP/2 ALPN negotiation from stalling Telegram long-polling connections on Windows. The approach mirrors the existing HTTP1_ONLY_DISPATCHER_OPTIONS pattern in src/infra/net/undici-runtime.ts and consistently covers every code path including the env-proxy fallback to a direct Agent.

Confidence Score: 5/5

Safe to merge; all dispatcher paths correctly receive allowH2: false and the only finding is a trivial dead-code ternary.

All four dispatcher construction paths are consistently patched and the change matches the established pattern in the core fetch-guard. The sole finding is a P2 style issue (an always-true typeof guard) that has no runtime impact.

No files require special attention.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/telegram/src/fetch.ts
Line: 281

Comment:
**Redundant ternary on always-string field**

`policy.proxyUrl` is typed as `string` in the `explicit-proxy` variant of `PinnedDispatcherPolicy` (see `src/infra/net/ssrf.ts`), so the `typeof … === "string"` check is always `true` and the `policy.proxyUrl!` else-branch is dead code. The whole expression simplifies to `policy.proxyUrl`.

```suggestion
          uri: policy.proxyUrl,
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(telegram): disable HTTP/2 for all Te..." | Re-trigger Greptile

} satisfies ConstructorParameters<typeof ProxyAgent>[0])
: policy.proxyUrl;
: ({
uri: typeof policy.proxyUrl === "string" ? policy.proxyUrl : policy.proxyUrl!,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Redundant ternary on always-string field

policy.proxyUrl is typed as string in the explicit-proxy variant of PinnedDispatcherPolicy (see src/infra/net/ssrf.ts), so the typeof … === "string" check is always true and the policy.proxyUrl! else-branch is dead code. The whole expression simplifies to policy.proxyUrl.

Suggested change
uri: typeof policy.proxyUrl === "string" ? policy.proxyUrl : policy.proxyUrl!,
uri: policy.proxyUrl,
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/telegram/src/fetch.ts
Line: 281

Comment:
**Redundant ternary on always-string field**

`policy.proxyUrl` is typed as `string` in the `explicit-proxy` variant of `PinnedDispatcherPolicy` (see `src/infra/net/ssrf.ts`), so the `typeof … === "string"` check is always `true` and the `policy.proxyUrl!` else-branch is dead code. The whole expression simplifies to `policy.proxyUrl`.

```suggestion
          uri: policy.proxyUrl,
```

How can I resolve this? If you propose a fix, please make it concise.

@steipete

Copy link
Copy Markdown
Contributor

Maintainer triage: correct root cause for #66885, but I would not merge this standalone yet.

Code shape looks right: every Telegram dispatcher path in extensions/telegram/src/fetch.ts should force HTTP/1.1 with allowH2: false. That matches the existing core undici workaround and the Windows IPv6/HTTP2 stall report.

Blockers before merge:

Suggested fix: rebase on #68128 or fold this into #68128 by adding allowH2: false to the shared pool options helper, plus fetch.test.ts assertions for direct, explicit proxy, env proxy, and env-proxy fallback direct agent.

@steipete

Copy link
Copy Markdown
Contributor

Thanks. I landed this via #69476 / 60fea81, with allowH2: false moved into the shared Telegram dispatcher pool options so Agent, ProxyAgent, and EnvHttpProxyAgent all get the same HTTP/1-only behavior. Closing this PR as superseded by the landed integration.

@steipete steipete closed this Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Telegram polling stall + subagent announce timeout on Windows (4.12) — undici HTTP/2 root cause

2 participants