Skip to content

fix(telegram): preserve HTTP proxy env in global dispatcher workaround#29940

Merged
vincentkoc merged 5 commits intomainfrom
vincentkoc-code/telegram-proxy-env-http-agent-fix
Mar 1, 2026
Merged

fix(telegram): preserve HTTP proxy env in global dispatcher workaround#29940
vincentkoc merged 5 commits intomainfrom
vincentkoc-code/telegram-proxy-env-http-agent-fix

Conversation

@vincentkoc
Copy link
Member

Summary

  • replace the global dispatcher override in src/telegram/fetch.ts from Agent to EnvHttpProxyAgent
  • preserve Node 22 autoSelectFamily behavior while restoring HTTP_PROXY/HTTPS_PROXY support for outbound requests
  • add regression hardening in Telegram proxy path to assert we never mutate the global dispatcher there

Why

Issue #26207 reports a regression introduced in 2026.2.24 where setGlobalDispatcher(new Agent(...)) bypasses env proxy settings for process-wide outbound fetch calls.

Testing

  • pnpm vitest run src/telegram/fetch.test.ts src/telegram/network-config.test.ts src/telegram/proxy.test.ts

Fixes #26207
Supersedes #26239

@openclaw-barnacle openclaw-barnacle bot added channel: telegram Channel integration: telegram size: XS maintainer Maintainer-authored PR labels Feb 28, 2026
@vincentkoc vincentkoc added the dedupe:parent Primary canonical item in dedupe cluster label Feb 28, 2026
nikolasdehor

This comment was marked as spam.

@vincentkoc vincentkoc marked this pull request as ready for review March 1, 2026 21:14
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 1, 2026

Greptile Summary

This PR fixes a regression in version 2026.2.24 where the global dispatcher workaround for Node 22's autoSelectFamily issue inadvertently broke environment proxy support. The fix replaces Agent with EnvHttpProxyAgent in src/telegram/fetch.ts, which preserves both the IPv4 fallback behavior AND respects HTTP_PROXY/HTTPS_PROXY environment variables for outbound requests.

Key changes:

  • Replaced Agent with EnvHttpProxyAgent in the global dispatcher workaround (preserves env proxy settings)
  • Updated all related tests to reflect the new agent type
  • Added regression hardening in proxy tests to ensure the explicit proxy path never mutates the global dispatcher
  • Added documentation explaining why proxy dispatching must remain request-scoped

The fix is surgical and well-tested, with comprehensive test coverage verifying the behavior change.

Confidence Score: 5/5

  • This PR is safe to merge with no identified risks
  • The change is a minimal, well-isolated fix that swaps one undici agent type for another compatible type. EnvHttpProxyAgent extends Agent and supports the same constructor options, so the change is a drop-in replacement. All tests have been properly updated and pass, including new regression tests. The fix directly addresses the reported issue without introducing side effects.
  • No files require special attention

Last reviewed commit: 5bdef54

@vincentkoc vincentkoc merged commit e604934 into main Mar 1, 2026
28 checks passed
@vincentkoc vincentkoc deleted the vincentkoc-code/telegram-proxy-env-http-agent-fix branch March 1, 2026 21:21
CyberK13 pushed a commit to CyberK13/clawdbot that referenced this pull request Mar 1, 2026
openclaw#29940)

* fix(telegram): preserve HTTP proxy env in global dispatcher workaround

* telegram: document request-scoped proxy dispatcher constraint

* telegram: assert proxy path never mutates global dispatcher

* changelog: credit telegram proxy env regression fix

---------

Co-authored-by: Rylen Anil <rylen.anil@gmail.com>
ansh pushed a commit to vibecode/openclaw that referenced this pull request Mar 2, 2026
openclaw#29940)

* fix(telegram): preserve HTTP proxy env in global dispatcher workaround

* telegram: document request-scoped proxy dispatcher constraint

* telegram: assert proxy path never mutates global dispatcher

* changelog: credit telegram proxy env regression fix

---------

Co-authored-by: Rylen Anil <rylen.anil@gmail.com>
steipete pushed a commit to Sid-Qin/openclaw that referenced this pull request Mar 2, 2026
openclaw#29940)

* fix(telegram): preserve HTTP proxy env in global dispatcher workaround

* telegram: document request-scoped proxy dispatcher constraint

* telegram: assert proxy path never mutates global dispatcher

* changelog: credit telegram proxy env regression fix

---------

Co-authored-by: Rylen Anil <rylen.anil@gmail.com>
safzanpirani pushed a commit to safzanpirani/clawdbot that referenced this pull request Mar 2, 2026
openclaw#29940)

* fix(telegram): preserve HTTP proxy env in global dispatcher workaround

* telegram: document request-scoped proxy dispatcher constraint

* telegram: assert proxy path never mutates global dispatcher

* changelog: credit telegram proxy env regression fix

---------

Co-authored-by: Rylen Anil <rylen.anil@gmail.com>
steipete pushed a commit to Sid-Qin/openclaw that referenced this pull request Mar 2, 2026
openclaw#29940)

* fix(telegram): preserve HTTP proxy env in global dispatcher workaround

* telegram: document request-scoped proxy dispatcher constraint

* telegram: assert proxy path never mutates global dispatcher

* changelog: credit telegram proxy env regression fix

---------

Co-authored-by: Rylen Anil <rylen.anil@gmail.com>
robertchang-ga pushed a commit to robertchang-ga/openclaw that referenced this pull request Mar 2, 2026
openclaw#29940)

* fix(telegram): preserve HTTP proxy env in global dispatcher workaround

* telegram: document request-scoped proxy dispatcher constraint

* telegram: assert proxy path never mutates global dispatcher

* changelog: credit telegram proxy env regression fix

---------

Co-authored-by: Rylen Anil <rylen.anil@gmail.com>
hanqizheng pushed a commit to hanqizheng/openclaw that referenced this pull request Mar 2, 2026
openclaw#29940)

* fix(telegram): preserve HTTP proxy env in global dispatcher workaround

* telegram: document request-scoped proxy dispatcher constraint

* telegram: assert proxy path never mutates global dispatcher

* changelog: credit telegram proxy env regression fix

---------

Co-authored-by: Rylen Anil <rylen.anil@gmail.com>
execute008 pushed a commit to execute008/openclaw that referenced this pull request Mar 2, 2026
openclaw#29940)

* fix(telegram): preserve HTTP proxy env in global dispatcher workaround

* telegram: document request-scoped proxy dispatcher constraint

* telegram: assert proxy path never mutates global dispatcher

* changelog: credit telegram proxy env regression fix

---------

Co-authored-by: Rylen Anil <rylen.anil@gmail.com>
dorgonman pushed a commit to kanohorizonia/openclaw that referenced this pull request Mar 3, 2026
openclaw#29940)

* fix(telegram): preserve HTTP proxy env in global dispatcher workaround

* telegram: document request-scoped proxy dispatcher constraint

* telegram: assert proxy path never mutates global dispatcher

* changelog: credit telegram proxy env regression fix

---------

Co-authored-by: Rylen Anil <rylen.anil@gmail.com>
sachinkundu pushed a commit to sachinkundu/openclaw that referenced this pull request Mar 6, 2026
openclaw#29940)

* fix(telegram): preserve HTTP proxy env in global dispatcher workaround

* telegram: document request-scoped proxy dispatcher constraint

* telegram: assert proxy path never mutates global dispatcher

* changelog: credit telegram proxy env regression fix

---------

Co-authored-by: Rylen Anil <rylen.anil@gmail.com>
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
openclaw#29940)

* fix(telegram): preserve HTTP proxy env in global dispatcher workaround

* telegram: document request-scoped proxy dispatcher constraint

* telegram: assert proxy path never mutates global dispatcher

* changelog: credit telegram proxy env regression fix

---------

Co-authored-by: Rylen Anil <rylen.anil@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram dedupe:parent Primary canonical item in dedupe cluster maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 2026.2.24 regression — setGlobalDispatcher breaks HTTP proxy for all outbound requests

3 participants