listr2: [Bug]: SIGINT listener added, but not removed, causing unwanted behavior

Replication of the Problem

Here’s a GIF demonstrating the problem using this Replit:

Recording

Problem

A SIGINT listener is being added here, but at no point does it ever get removed. This causes two issues:

  1. The first already-completed list get reprinted to stdout.
  2. Any currently running lists do not have their tasks updated to a “failed” state, because the first list’s SIGINT listener calls process.exit(127).

Environment

In the Replit, it’s using Node.js v18.12.1 and listr v8.0.2.

Log Output

Here's the final text from the GIF above.


~/listr2-sigint-bug$ node index.js
✖ Example task
~/listr2-sigint-bug$ node index.js
✔ Example task
⠙ Waiting for user to hit Ctrl-C...
^C✔ Example task


### Preflight

- [X] Read/Search existing issues and the provided [documentation](https://listr2.kilic.dev).
- [X] Be sure to not open an issue in the [looking for contributions section](/repository/contributions.html#looking-for-contributions).
- [X] Checking the latest version of the software to confirm it has not been fixed already.

About this issue

  • Original URL
  • State: closed
  • Created 3 months ago
  • Comments: 16 (6 by maintainers)

Commits related to this issue

Most upvoted comments

What Listr2 should be doing is calling process.removeListener() once a task list is done running. That will remove the listener so that Node.js doesn’t call it when SIGINT is received.