v3: fixed linter error, code format
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 41s

This commit is contained in:
khannurien
2026-06-22 17:31:21 +00:00
parent a1b71ad0c8
commit 26f5abfa4e
12 changed files with 31 additions and 39 deletions

View File

@@ -94,17 +94,14 @@ export async function fetchWithTimeout(
url: string,
timeoutMs = 5000,
): Promise<Response> {
async function attempt(
extraInit?: Record<string, unknown>,
): Promise<Response> {
async function attempt(): Promise<Response> {
const controller = new AbortController();
const timer = setTimeout(() => controller.abort(), timeoutMs);
try {
return await fetch(url, {
signal: controller.signal,
headers: FETCH_HEADERS,
...extraInit,
} as RequestInit);
});
} finally {
clearTimeout(timer);
}
@@ -117,18 +114,10 @@ export async function fetchWithTimeout(
throw err;
}
// Retry 1: allowInsecureCertificates handles expired / self-signed certs.
const client = Deno.createHttpClient({ allowInsecureCertificates: true });
try {
return await attempt({ client });
} catch {
/* UnsupportedSignatureAlgorithm etc. — rustls can't help */
} finally {
client.close();
}
// Retry 2: curl uses its own TLS stack and supports a wider set of
// certificate algorithms that Deno/rustls rejects.
// Deno/rustls rejected the server's TLS certificate (expired, self-signed,
// or an unsupported signature algorithm) and offers no way to override
// verification programmatically. Fall back to a `curl --insecure`
// subprocess, which uses its own TLS stack.
const curlRes = await fetchViaCurl(url, timeoutMs);
if (curlRes) return curlRes;