From 7150268f840cf519f900d07f75dc74f2dd928fca Mon Sep 17 00:00:00 2001 From: spiceoogway Date: Fri, 30 Jan 2026 02:21:37 -0500 Subject: [PATCH] fix(telegram): use undici fetch for proxy to fix dispatcher option Fixes #4038 The global fetch in Node.js doesn't support undici's dispatcher option, which is required for ProxyAgent to work. This fix imports fetch from undici directly to enable proper proxy support for Telegram API calls. Root cause: makeProxyFetch() was using global fetch with { dispatcher: agent }, but Node.js's global fetch ignores the dispatcher option. Using undici.fetch ensures the ProxyAgent dispatcher is properly respected. Tested: Build passes, TypeScript compilation successful. --- src/telegram/proxy.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/telegram/proxy.ts b/src/telegram/proxy.ts index 19d53d569..84251d7fe 100644 --- a/src/telegram/proxy.ts +++ b/src/telegram/proxy.ts @@ -1,11 +1,11 @@ // @ts-nocheck -import { ProxyAgent } from "undici"; +import { ProxyAgent, fetch as undiciFetch } from "undici"; import { wrapFetchWithAbortSignal } from "../infra/fetch.js"; export function makeProxyFetch(proxyUrl: string): typeof fetch { const agent = new ProxyAgent(proxyUrl); return wrapFetchWithAbortSignal((input: RequestInfo | URL, init?: RequestInit) => { const base = init ? { ...init } : {}; - return fetch(input, { ...base, dispatcher: agent }); + return undiciFetch(input, { ...base, dispatcher: agent }); }); }