Skip to content

Pausing readline pauses SIGINTs #34619

Open
@devsnek

Description

@devsnek

So lets say you are making a cute little CLI app, and you write this code:

const rl = readline.createInterface(...);
rl.on('SIGINT', () => {
  console.log('bye!');
  process.exit();
});
rl.on('line', (line) => {
  rl.pause();
  compute(line).then(() => {
    rl.resume();
  });
});

You will discover that, while the interface is paused, the SIGINT event stops working. This is because pausing readline just pauses the underlying input stream. To fix this I think we would need to decouple that and have readline have an internal buffer of events. Alternatively we could say that people just shouldn't use readline pausing in this case, and do the line buffering themselves (that being said, I don't know how you would do this yourself or if it is even possible).

cc @nodejs/readline

Metadata

Metadata

Assignees

No one assigned

    Labels

    readlineIssues and PRs related to the built-in readline module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions