fix(telegram): gate native fetch to bun
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
// BAN compatibility: force native fetch to avoid grammY's node-fetch shim under Bun.
|
||||
export function resolveTelegramFetch(proxyFetch?: typeof fetch): typeof fetch {
|
||||
const fetchImpl = proxyFetch ?? globalThis.fetch;
|
||||
// BAN compatibility: force native fetch under Bun; keep grammY defaults on Node.
|
||||
export function resolveTelegramFetch(
|
||||
proxyFetch?: typeof fetch,
|
||||
): typeof fetch | undefined {
|
||||
if (proxyFetch) return proxyFetch;
|
||||
const isBun = "Bun" in globalThis || Boolean(process?.versions?.bun);
|
||||
if (!isBun) return undefined;
|
||||
const fetchImpl = globalThis.fetch;
|
||||
if (!fetchImpl) {
|
||||
throw new Error("fetch is not available; set telegram.proxy in config");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user