From bb95199795196d46305c1b894858ba491ed652ef Mon Sep 17 00:00:00 2001 From: "Jiaxiao (mossaka) Zhou" Date: Tue, 7 Apr 2026 23:32:11 +0000 Subject: [PATCH] fix: guard null execSync return in benchmark exec helper When exec() is called with { stdio: "ignore" }, execSync returns null instead of a string. Calling .trim() on null crashes with TypeError, breaking the entire benchmark workflow on the first test. Also improve JSON validation in performance-monitor.yml to catch empty files, since `jq empty` passes on empty input. Discovered during end-to-end validation of the benchmark system. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/performance-monitor.yml | 4 ++++ scripts/ci/benchmark-performance.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/performance-monitor.yml b/.github/workflows/performance-monitor.yml index 3c698692f..4772a3cdd 100644 --- a/.github/workflows/performance-monitor.yml +++ b/.github/workflows/performance-monitor.yml @@ -64,6 +64,10 @@ jobs: - name: Validate benchmark JSON run: | + if [ ! -s benchmark-results.json ]; then + echo "ERROR: benchmark-results.json is empty" + exit 1 + fi if ! jq empty benchmark-results.json 2>/dev/null; then echo "ERROR: benchmark-results.json is not valid JSON" cat benchmark-results.json diff --git a/scripts/ci/benchmark-performance.ts b/scripts/ci/benchmark-performance.ts index 63aafabe2..0dc9d196b 100644 --- a/scripts/ci/benchmark-performance.ts +++ b/scripts/ci/benchmark-performance.ts @@ -56,7 +56,7 @@ const THRESHOLDS: Record = { // ── Helpers ──────────────────────────────────────────────────────── function exec(cmd: string, opts?: ExecSyncOptions): string { - return execSync(cmd, { encoding: "utf-8", timeout: 120_000, ...opts }).trim(); + return (execSync(cmd, { encoding: "utf-8", timeout: 120_000, ...opts }) ?? "").trim(); } function timeMs(fn: () => void): number {