Skip to content

fix(cli): make SIGINT monitor shutdown handler async#26

Open
W4ilops wants to merge 1 commit into
nirholas:mainfrom
W4ilops:fix/cli-sigint-await-import
Open

fix(cli): make SIGINT monitor shutdown handler async#26
W4ilops wants to merge 1 commit into
nirholas:mainfrom
W4ilops:fix/cli-sigint-await-import

Conversation

@W4ilops
Copy link
Copy Markdown

@W4ilops W4ilops commented Apr 11, 2026

What does this PR do?

Fixes a CLI syntax error in src/cli/index.js caused by using await import(...) inside a non-async SIGINT callback.

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Refactoring
  • New skill (skills/*/SKILL.md)
  • Test fix
  • Other

Runtime context

  • OS: Arch Linux
  • Node.js: v20.20.2

Problem

The CLI failed before startup with:

SyntaxError: Unexpected reserved word

The issue came from this pattern:

process.on('SIGINT', () => {
  const { stopMonitor: stop } = await import('../analytics/reputation.js');
  stop(monitor.id);
  console.log(chalk.yellow('\nMonitor stopped.'));
  process.exit(0);
});

Root cause

await was used inside a callback that was not marked async.

Fix

Changed the handler to:

process.on('SIGINT', async () => {
  const { stopMonitor: stop } = await import('../analytics/reputation.js');
  stop(monitor.id);
  console.log(chalk.yellow('\nMonitor stopped.'));
  process.exit(0);
});

Validation

Verified locally with:

npm run cli -- --help
npm run cli -- tweets paoloanzn --limit 10

Both commands worked successfully after the patch.

Copilot AI review requested due to automatic review settings April 11, 2026 14:48
@W4ilops W4ilops requested a review from nirholas as a code owner April 11, 2026 14:48
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 11, 2026

@devwail is attempting to deploy a commit to the kaivocmenirehtacgmailcom's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a CLI startup syntax error by making the SIGINT shutdown handler asynchronous so it can legally use await import(...) within the monitor command flow.

Changes:

  • Updated the process.on('SIGINT', ...) handler in the monitor command to be async, enabling await import('../analytics/reputation.js').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants