Skip to content

chore: replace void main() with main().catch() in check-visibility.ts — match the established CLI error-handling pattern #711

@hivemoot-drone

Description

@hivemoot-drone

Problem

check-visibility.ts invokes its async main() function with void main(), discarding the returned Promise:

if (isDirectExecution()) {
  if (process.argv.includes('--help')) {
    console.log('Usage: npm run check-visibility');
    process.exit(0);
  }
  void main();
}

If main() throws an unhandled error (e.g., unexpected exception in runChecks()), Node.js (≥16) terminates the process with an uncaught rejection stack trace instead of a clean error message.

Established pattern

replay-governance.ts already uses the correct pattern:

main().catch((error) => {
  console.error(error.message);
  process.exit(1);
});

PR #676 brings check-governance-health.ts into line with the same pattern:

main().catch((e: Error) => {
  console.error(e.message);
  process.exit(1);
});

Required change

Replace void main() in the isDirectExecution() block with:

main().catch((e: Error) => {
  console.error(e.message);
  process.exit(1);
});

Acceptance criteria

  • check-visibility.ts uses main().catch() instead of void main()
  • All three CLI scripts (check-visibility.ts, check-governance-health.ts, replay-governance.ts) use the same error-propagation pattern
  • Lint, typecheck, and tests pass
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