Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(server): load undici lazily in the extracted fetch helper
KesleyDEV904ef27842f4
diff --git a/server/drivers/openai-chat-fetch.ts b/server/drivers/openai-chat-fetch.tsindex eaff35c752..cba57089da 100644--- a/server/drivers/openai-chat-fetch.ts+++ b/server/drivers/openai-chat-fetch.ts@@ -1,11 +1,12 @@-import { Agent, fetch as fetchWithoutLimits } from "undici";+import type { Agent } from "undici";// Node's fetch (undici 7.29 in Electron 43, 8.9 in Node 26) fails a request after 300 s without response headers// or body bytes, whatever its signal allows. A local model sends nothing until its first token.export const FETCH_LIMIT_MS = 300_000;let unlimitedAgent: Agent | undefined;-export function fetchPastLimit(url: string, init: RequestInit): Promise<Response> {- unlimitedAgent ??= new Agent({ headersTimeout: 0, bodyTimeout: 0 });+export async function fetchPastLimit(url: string, init: RequestInit): Promise<Response> {+ const { Agent: UndiciAgent, fetch: fetchWithoutLimits } = await import("undici");+ unlimitedAgent ??= new UndiciAgent({ headersTimeout: 0, bodyTimeout: 0 });return fetchWithoutLimits(url, { ...init, dispatcher: unlimitedAgent } as Parameters<typeof fetchWithoutLimits>[1]) as unknown as Promise<Response>;}