Inquirer.js icon indicating copy to clipboard operation
Inquirer.js copied to clipboard

Nested call after prompt with async validation is not displayed.

Open iKurisu opened this issue 5 years ago • 3 comments

inquirer
  .prompt([
    {
      type: "list",
      name: "action",
      message: "Choose action",
      choices: ["Sign in", "Sign up"]
    },
    {
      type: "input",
      name: "username",
      message: "Enter username",
      validate(username, { action }) {
        return new Promise(res => {
          // Check if user exists in a database and resolve the answer.
        });
      }
    }
  ])
  .then(answers => {
    // Make some queries to the database.

    inquirer.prompt({
      type: "list",
      name: "roomAction",
      message: "No rooms found",
      choices: ["Create room", "Join room"]
    });
  });

Produces:

? Choose action: Sign in
? Enter username: Someusername
(and it gets stuck here)

The same happens when the promise is resolved after a timeout, but it doesn't when the promise is instantly resolved.

iKurisu avatar Jan 04 '20 08:01 iKurisu

Same problem here, can we expect a fix?

ptu14 avatar Sep 07 '20 15:09 ptu14

Same here, i noticed that this only occurs on windows (PowerShell / cmd). It is properly working on bash.

wszydlak avatar Sep 08 '20 08:09 wszydlak

@wszydlak thanks! I tried it in bash and it's worked. I spent more time with this problem and i also notice that it's only stuck when async validation is on the last question.

ptu14 avatar Sep 08 '20 09:09 ptu14