unjs / consola

🐨 Elegant Console Logger for Node.js and Browser
Other
6.12k stars 175 forks source link

Concurrent interaction exception #198

Closed wss-git closed 1 year ago

wss-git commented 1 year ago

Describe the feature

inoperable ‘Deploy to the production ’

const { consola } = require("consola");

(async () => {
  await Promise.all([
    a(),
    b(),
  ])
})()

async function a() {
  await consola.prompt("Deploy to the production?", {
    type: "confirm",
  });
}

async function b() {
  await consola.prompt("bbbbbb?", {
    type: "confirm",
  });
}

image

Additional information

nozomuikuta commented 1 year ago

Do you mean that you want to make the 2 prompts operable at the same time and move cursor between them with up/down arrow keys?

If so, such a feature is not supported at least at the moment as far as I know.


By the way, generally, it is supposed to be that only one prompt is used at a time.

I'm no so sure how it happens but the prompt executed first seems to be answered as "yes" because the next prompt is executed and have a control on user input (note: "Yes" is default answer when initialValue option is not provided to a confirm prompt).

This happens because you use Promise.all() that awaits promises parallelly. You should sequentially await confirm prompt promises.

const { consola } = require("consola");

(async () => {
  await a()
  await b()
})()

async function a() {
  await consola.prompt("Deploy to the production?", {
    type: "confirm",
  });
}

async function b() {
  await consola.prompt("bbbbbb?", {
    type: "confirm",
  });
}
wss-git commented 1 year ago

e... It seems that our project is not very suitable for this thing anymore, we have such a scenario. Thank you for your reply