Skip to content

Node.js readline.question still prompts question after readline.close #42450

Closed

Description

@qiulang

What is the problem this feature will solve?

When I close readline, readline.question still prompts the question, but the callback won't be called and the process hangs!

const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
  })
  
  readline.question(`What's your name?`, name => {
    console.log(`Hi ${name}!`)
    readline.close()
    readline.question(`How are you?`, how => {
      console.log(`Good to know you are ${how}!`)
      //readline.close() should close here
    })
  })

What is the feature you are proposing to solve the problem?

If readline.close() I think it is better readline.question not prompt, so no hang either.

What alternatives have you considered?

No response

Activity

  1. added
    feature request
    on Mar 24, 2022
  2. changed the title [-]Node.js readline.question still prompts question when readline.close[/-] [+]Node.js readline.question still prompts question after readline.close[/+] on Mar 24, 2022
  3. added
    readline
    feature request
    and removed
    feature request
    on Mar 24, 2022
  4. Trott commented on Mar 24, 2022

    @Trott
    Member

    @nodejs/readline

  5. removed
    feature request
    on Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    readline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions