From a8f3a579d4f805d3b51005d5c08915a580d3eb90 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 15 Feb 2026 13:44:46 +0000 Subject: [PATCH] perf(telegram): lazy import proxy + timeout deps in audit --- src/telegram/audit.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/telegram/audit.ts b/src/telegram/audit.ts index 48e4a923f8b..b86953fa1b1 100644 --- a/src/telegram/audit.ts +++ b/src/telegram/audit.ts @@ -1,7 +1,5 @@ import type { TelegramGroupConfig } from "../config/types.js"; import { isRecord } from "../utils.js"; -import { fetchWithTimeout } from "../utils/fetch-timeout.js"; -import { makeProxyFetch } from "./proxy.js"; const TELEGRAM_API_BASE = "https://api.telegram.org"; @@ -87,7 +85,12 @@ export async function auditTelegramGroupMembership(params: { }; } - const fetcher = params.proxyUrl ? makeProxyFetch(params.proxyUrl) : fetch; + // Lazy import to avoid pulling `undici` (ProxyAgent) into cold-path callers that only need + // `collectTelegramUnmentionedGroupIds` (e.g. config audits). + const fetcher = params.proxyUrl + ? (await import("./proxy.js")).makeProxyFetch(params.proxyUrl) + : fetch; + const { fetchWithTimeout } = await import("../utils/fetch-timeout.js"); const base = `${TELEGRAM_API_BASE}/bot${token}`; const groups: TelegramGroupMembershipAuditEntry[] = [];