Inquirer.js: Input issue with Node 11?

Created on 31 Jan 2019  路  7Comments  路  Source: SBoudrias/Inquirer.js

Hi,

first, a big thank you for this awesome library! It's made my life considerably easier when building command line apps.

I did run into a very strange issue today though: after upgrading to the Node 11 line (I tested both 11.8.0 and 11.9.0), I am finding that selection input in a list is messed up.

Here's an absolutely minimal reproduction:

const inquirer = require('inquirer')

async function main () {
  let res = await inquirer.prompt([
    {name: 'test', type: 'list', message: 'question1?', choices: [{name: 'a', value: 1}, {name: 'b', value: 2}, {name: 'c', value: 3}], default: 1}
  ])
}

main()

Install inquirer and run this super basic script with Node as usual.

This obviously results in this prompt:

? question1? (Use arrow keys)
> a
  b
  c

I would expect the arrow keys to navigate this list in the obvious way; what ends up happening though is that inputs are repeated, i.e. one press of the down arrow moves to b and then immediately to c.

This occurs in any terminal (cmd.exe, Powershell, Git Bash/MinGW). As far as I can tell without a real Linux box on hand, this seems to be Windows specific (a quick run of the above script in the Docker images for Node 10 and Node 11 both worked correctly).

If I uninstall Node 11 and return to Node 10 LTS (10.15.1 currently), the problem disappears.

Any thoughts?

Most helpful comment

This is fixed with Node 11.10.0!

All 7 comments

Any chance you called inquirer 2 times? Maybe there's some issue with listeners cleanup on the readline?

I've the same problem on a windows machine with node 11.9.0 too.

Any chance you called inquirer 2 times? Maybe there's some issue with listeners cleanup on the readline?

I'm literally invoking the 5 line script so that's unlikely!

I've actually narrowed down the issue to Node 11.8.0. The exact same script behaves correctly with 11.7.0 and fails with 11.8.0.

Currently git bisecting the Node repo and rebuilding to try and narrow it down, which isn't exactly how I was intending to spend my work day but I can't have this internal tool I built start misbehaving just as we were starting to deploy it to everyone 馃槺

I suppose this means this issue isn't really for you but once I know the exact commit in Node that breaks this I might need your expert opinion on what they broke!

I can confirm that it still persists in node 11.9 :(

The underlying issue in libuv has been fixed and the relevant upgrade of the dependencies was just merged in Node: https://github.com/nodejs/node/pull/26037

So the fix for this should be an upcoming in Node 11.9.1 soon, I guess!

Thanks a ton for following up on this @Ezekiel-DA !!

This is fixed with Node 11.10.0!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dantasfiles picture dantasfiles  路  3Comments

alex-ppg picture alex-ppg  路  3Comments

lvjiaxuan picture lvjiaxuan  路  6Comments

sindresorhus picture sindresorhus  路  4Comments

bapti picture bapti  路  6Comments