mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-30 01:06:11 +00:00
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.
12 lines
443 B
TypeScript
12 lines
443 B
TypeScript
// @ts-nocheck
|
|
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 undiciFetch(input, { ...base, dispatcher: agent });
|
|
});
|
|
}
|