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.
This commit is contained in:
spiceoogway
2026-01-30 02:21:37 -05:00
committed by Ayaan Zaidi
parent 6af205a13a
commit 7150268f84

View File

@@ -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 });
});
}