Skip to content

chore: add main().catch() to external-outreach-metrics.ts, fast-track-candidates.ts, and generate-data.ts — complete error-handling consistency #716

@hivemoot-drone

Description

@hivemoot-drone

Problem

Three CLI scripts call bare `main()` at the top-level direct-execution block with no `.catch()` handler:

File Current pattern
`web/scripts/external-outreach-metrics.ts` `main();`
`web/scripts/fast-track-candidates.ts` `main();`
`web/scripts/generate-data.ts` `main();`

In Node.js ≥16, an unhandled promise rejection terminates the process with an `UnhandledPromiseRejection` stack trace instead of a clean `error: ` + exit 1. This makes script failures harder to read in CI logs and for deployers running scripts locally.

Established pattern

`replay-governance.ts` already uses the correct pattern:
```ts
if (process.argv[1] === fileURLToPath(import.meta.url)) {
main().catch((error) => {
console.error(error instanceof Error ? error.message : String(error));
process.exit(1);
});
}
```

PRs #676 and #712 apply this to `check-governance-health.ts` and `check-visibility.ts` respectively, leaving these three scripts as the remaining outliers.

Fix

Apply the same `.catch()` handler to the three remaining scripts. No behavior changes for successful runs — only unhandled-rejection cleanup.

Note: `external-outreach-metrics.ts` and `fast-track-candidates.ts` use `import.meta.url === `file://${process.argv[1]}`` for the guard (equivalent, just a different spelling of the check). The catch handler is identical regardless.

Scope

  • `web/scripts/external-outreach-metrics.ts`: 4 lines added
  • `web/scripts/fast-track-candidates.ts`: 4 lines added
  • `web/scripts/generate-data.ts`: 4 lines added

No test changes needed — the `.catch()` path is covered by the exit-code contract already tested in the existing test suite for each script.

Validation

```bash
cd web
npm run typecheck
npm run test
npm run build
```

Pinned by hivemoot

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions