feat(devops): diagnose slow HK requests and dependency timings
CI / check (push) Successful in 2m0s
CI / deploy (push) Successful in 1m35s
CI / publish-container (push) Successful in 46s

This commit is contained in:
Simo committed 2026-09-11 09:48:19 +02:00
1 parent 3b76d063a6
commit 00e33623f7
42 files changed
+1335 -132

No files matched your search

+31 -26
View File
@@ -1,6 +1,7 @@
import { execFile } from "node:child_process";
import { existsSync, promises as fs } from "node:fs";
import { promisify } from "node:util";
import { measureDependency } from "@/lib/performance-diagnostics";
const execFileAsync = promisify(execFile);
@@ -46,10 +47,12 @@ export async function curlFetchText(
url: string,
timeoutMs = 30_000,
): Promise<string> {
const { stdout } = await execFileAsync(CURL_BIN, curlArgs(url, []), {
timeout: timeoutMs,
maxBuffer: 512 * 1024 * 1024,
});
const { stdout } = await measureDependency("external", () =>
execFileAsync(CURL_BIN, curlArgs(url, []), {
timeout: timeoutMs,
maxBuffer: 512 * 1024 * 1024,
}),
);
return stdout;
}
@@ -62,28 +65,30 @@ export async function curlDownload(
): Promise<{ ok: boolean; size: number }> {
try {
const cookieArgs = cookieHeader ? ["-H", `Cookie: ${cookieHeader}`] : [];
await execFileAsync(
CURL_BIN,
[
"-sSL",
"--compressed",
"--fail",
"--max-time",
"30",
"--connect-timeout",
"10",
"-A",
CURL_USER_AGENT,
"-H",
"Accept: application/octet-stream,*/*;q=0.9",
"-H",
"Accept-Language: en-US,en;q=0.9",
...cookieArgs,
"-o",
destPath,
url,
],
{ timeout: timeoutMs },
await measureDependency("external", () =>
execFileAsync(
CURL_BIN,
[
"-sSL",
"--compressed",
"--fail",
"--max-time",
"30",
"--connect-timeout",
"10",
"-A",
CURL_USER_AGENT,
"-H",
"Accept: application/octet-stream,*/*;q=0.9",
"-H",
"Accept-Language: en-US,en;q=0.9",
...cookieArgs,
"-o",
destPath,
url,
],
{ timeout: timeoutMs },
),
);
const stat = await fs.stat(destPath);
return { ok: stat.size > 0, size: stat.size };