Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
qiulang opened this issue Mar 24, 2022 · 1 comment · Fixed by #42464
Closed

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

qiulang opened this issue Mar 24, 2022 · 1 comment · Fixed by #42464
Labels
readline Issues and PRs related to the built-in readline module.

Comments

@qiulang
Copy link

qiulang commented Mar 24, 2022

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

@qiulang qiulang added the feature request Issues that request new features to be added to Node.js. label Mar 24, 2022
@qiulang qiulang changed the title Node.js readline.question still prompts question when readline.close Node.js readline.question still prompts question after readline.close Mar 24, 2022
@Mesteery Mesteery added readline Issues and PRs related to the built-in readline module. feature request Issues that request new features to be added to Node.js. and removed feature request Issues that request new features to be added to Node.js. labels Mar 24, 2022
@Trott
Copy link
Member

Trott commented Mar 24, 2022

@nodejs/readline

@targos targos removed the feature request Issues that request new features to be added to Node.js. label Apr 4, 2022
nodejs-github-bot pushed a commit that referenced this issue Apr 8, 2022
resolve: #42450

PR-URL: #42464
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
xtx1130 pushed a commit to xtx1130/node that referenced this issue Apr 25, 2022
resolve: nodejs#42450

PR-URL: nodejs#42464
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
readline Issues and PRs related to the built-in readline module.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants