v3: fixed linter error, code format
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 41s
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 41s
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
import {
|
||||
APIErrorCode,
|
||||
APIException,
|
||||
type User,
|
||||
} from "../model/interfaces.ts";
|
||||
import { APIErrorCode, APIException, type User } from "../model/interfaces.ts";
|
||||
import { db, isUserRow, userRowToApi } from "../model/db.ts";
|
||||
import { notifyCommentOwnerLike } from "./notification-service.ts";
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import {
|
||||
APIErrorCode,
|
||||
APIException,
|
||||
type User,
|
||||
} from "../model/interfaces.ts";
|
||||
import { APIErrorCode, APIException, type User } from "../model/interfaces.ts";
|
||||
import { db, isUserRow, userRowToApi } from "../model/db.ts";
|
||||
import { notifyDumpOwnerUpvote } from "./notification-service.ts";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user