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 + }); 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) {