mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-05 06:42:12 +03:00
fix: NVIDIA NIM API key validation timeout (bypass proxy fetch patch) (#3226)
NVIDIA NIM validation bypasses the proxy-patched fetch (504 fix) + combined with #3116 reliable probe model + test. Integrated into release/v3.8.11.
This commit is contained in:
@@ -13,10 +13,13 @@ const FETCH_TIMEOUT_MS = parseInt(process.env.FETCH_TIMEOUT_MS || "", 10) || DEF
|
||||
|
||||
interface FetchTimeoutOptions extends RequestInit {
|
||||
timeoutMs?: number;
|
||||
/** Alternative fetch function to use instead of globalThis.fetch.
|
||||
* Pass getOriginalFetch() to bypass the proxy/TLS patch layer. */
|
||||
fetchFn?: typeof globalThis.fetch;
|
||||
}
|
||||
|
||||
export async function fetchWithTimeout(url: string | URL, options: FetchTimeoutOptions = {}) {
|
||||
const { timeoutMs = FETCH_TIMEOUT_MS, signal: externalSignal, ...fetchOptions } = options;
|
||||
const { timeoutMs = FETCH_TIMEOUT_MS, signal: externalSignal, fetchFn, ...fetchOptions } = options;
|
||||
|
||||
const controller = new AbortController();
|
||||
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
||||
@@ -31,7 +34,8 @@ export async function fetchWithTimeout(url: string | URL, options: FetchTimeoutO
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
const doFetch = fetchFn || globalThis.fetch;
|
||||
const response = await doFetch(url, {
|
||||
...fetchOptions,
|
||||
signal: controller.signal,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user