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

Multiple Questions on Windows 10 Hangs #767

Closed
jlkalberer opened this issue Jan 19, 2019 · 13 comments · Fixed by #879
Closed

Multiple Questions on Windows 10 Hangs #767

jlkalberer opened this issue Jan 19, 2019 · 13 comments · Fixed by #879

Comments

@jlkalberer
Copy link

jlkalberer commented Jan 19, 2019

Windows 10 - Version 1803 (OS Build 17134.523)
yarn - 1.9.4
npm - 6.0.1
node - v10.13.0

I dug into this a bit because of microsoft/appcenter-sdk-react-native#471 (comment)

Inquirer uses stdout to write to the command prompt. It looks like if this line is run, it will cause windows to "hang".
Also, it turns out that node 8.15.0 works with this code so it could also just be a regression

I think what is really going on is that the stream is just ending so we don't see any more output.

Here is a repro of the bug.

const readline = require("readline");

let index = 0;
const runQuestion = () => {
  index += 1;
  console.log(`Question ${index} - type something`);

  const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
  });

  rl.on("line", line => {
    console.log(`Received: ${line}`);

    rl.output.end();
    rl.pause();
    rl.close();

    runQuestion();
  });
};

runQuestion();

With this simple example removing rl.output.end() fixes things but the only way to work around it in inquirer is to remove the rl.close() line.

@mshima
Copy link
Contributor

mshima commented Jan 4, 2020

@SBoudrias
I've tracked back yeoman/generator#1098 to this issue.
It's reported in a lot of places, node.js included (nodejs/node#21210)

Removing rl.close(); fix the issue, but I don't know the consequences.
Maybe make it conditional for non windows.

@mshima
Copy link
Contributor

mshima commented Jan 4, 2020

Found porketta@91b4216 at nodejs/node#21771

@Diablohu
Copy link

Diablohu commented Jan 6, 2020

After this fix, there are more problems

  1. The process that run Inquirer.js will never end, make the program hang until killed manually
  2. The option of type list or checkbox cannot be selected. When input UP or DOWN, option will not be switched, instead the last input value showed up
    1

@SBoudrias SBoudrias reopened this Jan 6, 2020
@mshima
Copy link
Contributor

mshima commented Jan 6, 2020

Seems this have to be reverted.
@Diablohu what is your environment?
Is this a regression?

@Diablohu
Copy link

Diablohu commented Jan 6, 2020

@mshima
Windows 10 1909 (18363.476)
I tried both in PowerShell and the new Windows Terminal. They have the same problems

7.0.1 is fine
7.0.0 has the hang problem

@mshima
Copy link
Contributor

mshima commented Jan 6, 2020

@Diablohu node 8?

@Diablohu
Copy link

Diablohu commented Jan 6, 2020

I tried on both node 10 and 12. Has the same problem

@mshima
Copy link
Contributor

mshima commented Jan 6, 2020

Created a PR reverting last commit #881 and another with skip closing workaround #882.

@mshima
Copy link
Contributor

mshima commented Jan 6, 2020

Adding
process.stdin.unpipe(this.rl.input);
before

this.rl.output.end();
this.rl.pause();
this.rl.close();

fix the hang problem.

But not the list and checkbox problem.
That can related to other readline uses:

this.rl = readline.createInterface({
terminal: true,
input,
output
});

const rl = readline.createInterface({
terminal: true,
input,
output
});

@famanoder
Copy link

I use inquirer@7.0.1 then it fixed.

@yolilufei
Copy link

i met the same problem, here is my env

  • os macOs 11.5.1
  • shell zsh
  • node v14.*
  • inquirer v8.*

then i fixed the problem by revert the version with v7.*

@just-maik
Copy link

This Issue still exists for me. Using bun 1.1.3 on powershell Win 11 22H2. Tried via bunx @inquirer/demo@latest.

@SBoudrias
Copy link
Owner

Hi @just-maik, this is a bug you should report to bun (not here.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants