mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 21:17:27 +00:00
fix: warn when proxy env var is set but agent creation fails
This commit is contained in:
committed by
Peter Steinberger
parent
8c1e9949b3
commit
58cde87436
@@ -1,4 +1,5 @@
|
||||
import { EnvHttpProxyAgent, ProxyAgent, fetch as undiciFetch } from "undici";
|
||||
import { logWarn } from "../../logger.js";
|
||||
|
||||
/**
|
||||
* Create a fetch function that routes requests through the given HTTP proxy.
|
||||
@@ -38,8 +39,10 @@ export function resolveProxyFetchFromEnv(): typeof fetch | undefined {
|
||||
...(init as Record<string, unknown>),
|
||||
dispatcher: agent,
|
||||
}) as unknown as Promise<Response>) as typeof fetch;
|
||||
} catch {
|
||||
// Malformed proxy URL in env — fall back to direct fetch.
|
||||
} catch (err) {
|
||||
logWarn(
|
||||
`Proxy env var set but agent creation failed — falling back to direct fetch: ${err instanceof Error ? err.message : String(err)}`,
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user