From e857a5894c8df637e08bd9f54101ef0dbf958624 Mon Sep 17 00:00:00 2001 From: lodekeeper Date: Sat, 28 Mar 2026 15:25:10 +0000 Subject: [PATCH 1/2] fix: use parseAsync to propagate async handler errors to exit code The CLI used `void yargs(...).parse()` which discards the Promise from async command handlers. When a benchmark run throws (e.g. all benchmarks fail), the rejection is unhandled and the process exits with code 0 instead of 1. Switch to `.parseAsync()` so the async handler's rejection is properly caught by yargs and routed to the `.fail()` handler which calls `process.exit(1)`. The `.catch()` on parseAsync prevents an unhandled rejection warning since the `.fail()` handler already calls `process.exit(1)`. Ref: ChainSafe/lodestar#7484 --- src/cli/cli.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cli/cli.ts b/src/cli/cli.ts index 5dea40b..c5258f0 100644 --- a/src/cli/cli.ts +++ b/src/cli/cli.ts @@ -13,7 +13,7 @@ import {compare} from "./compare.ts"; import {CLIOptions, benchmarkOptions, fileCollectionOptions, storageOptions} from "./options.ts"; import {run} from "./run.ts"; -void yargs(hideBin(process.argv)) +yargs(hideBin(process.argv)) .env("BENCHMARK") .scriptName("benchmark") .command({ @@ -83,4 +83,7 @@ void yargs(hideBin(process.argv)) console.error(` ✖ ${errorMessage}\n`); process.exit(1); }) - .parse(); + .parseAsync() + .catch(() => { + // Error already handled by .fail() handler + }); From bcfa44f869a49da9633f5234ff9cf3f194589a86 Mon Sep 17 00:00:00 2001 From: lodekeeper Date: Sat, 28 Mar 2026 16:00:06 +0000 Subject: [PATCH 2/2] fix: gracefully handle comment posting errors on fork PRs Wrap postGaComment in try-catch so that HttpError (e.g. fork PRs lack pull-requests:write permission) logs a warning instead of propagating as a fatal error. The benchmark results themselves are unaffected. This is the same fix applied in PR #45 (fix/fail-on-benchmark-errors). --- src/cli/run.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/cli/run.ts b/src/cli/run.ts index 9430ce8..65cac0f 100644 --- a/src/cli/run.ts +++ b/src/cli/run.ts @@ -98,11 +98,17 @@ export async function run(opts_: FileCollectionOptions & StorageOptions & Benchm debug("detecting to post comment. skipPostComment: %o, isGaRun: %o", !opts.skipPostComment, isGaRun()); if (!opts.skipPostComment && isGaRun()) { - await postGaComment({ - commentBody: performanceReportComment(resultsComp), - tag: GithubCommentTagEnum.PerformanceReport, - commentOnPush: resultsComp.someFailed, - }); + try { + await postGaComment({ + commentBody: performanceReportComment(resultsComp), + tag: GithubCommentTagEnum.PerformanceReport, + commentOnPush: resultsComp.someFailed, + }); + } catch (e) { + // Don't fail the benchmark run due to comment posting errors + // (e.g. fork PRs lack pull-requests:write permission) + consoleLog(`Warning: Failed to post GitHub comment: ${(e as Error).message}`); + } } if (resultsComp.someFailed && !opts.noThrow) {