fix(telegram): preserve HTTP proxy env in global dispatcher workaround (#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>
This commit is contained in:
Vincent Koc
2026-03-01 13:21:01 -08:00
committed by GitHub
parent e7cafed424
commit e6049345db
5 changed files with 24 additions and 17 deletions

View File

@@ -1,6 +1,6 @@
import * as dns from "node:dns";
import * as net from "node:net";
import { Agent, setGlobalDispatcher } from "undici";
import { EnvHttpProxyAgent, setGlobalDispatcher } from "undici";
import type { TelegramNetworkConfig } from "../config/types.telegram.js";
import { resolveFetch } from "../infra/fetch.js";
import { createSubsystemLogger } from "../logging/subsystem.js";
@@ -46,7 +46,7 @@ function applyTelegramNetworkWorkarounds(network?: TelegramNetworkConfig): void
) {
try {
setGlobalDispatcher(
new Agent({
new EnvHttpProxyAgent({
connect: {
autoSelectFamily: autoSelectDecision.value,
autoSelectFamilyAttemptTimeout: 300,