Skip to content

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

Closed
@qiulang

Description

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

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