Skip to content

Double keypress in readline / process.stdin #25875

Closed
@Ezekiel-DA

Description

@Ezekiel-DA
  • Version: 11.8.0, 11.9.0
  • Platform: Windows 10 (x64)
  • Subsystem: console

This code produces repeated output:

const readline = require('readline')
const process = require('process')

let rl = readline.createInterface({terminal: true, input: process.stdin, output: process.stdout})
rl.resume()
rl.input.on('data', (chunk) => {
  console.log(`Received ${chunk.length} bytes of data - content was: ${chunk}`)
})

Run this with Node 11.8.0 or above and press the down arrow; two messages are produced:

Received 3 bytes of data - content was:

Received 3 bytes of data - content was:

Revert to Node 11.7.0, a single message is produced.

Received 3 bytes of data - content was:

This breaks, among many things, scrolling through menus in Inquirer.js: SBoudrias/Inquirer.js#778

This appears to be Windows specific (as far as I could tell, I was only able to test on a Linux VM via Docker right now).

Git bisect tells me this issue first appeared with c0859d7, which upgraded libuv to 1.25.0.

I'll keep digging into libuv (I already have an idea of where the problem was introduced in 1.25.0) but since this impacts Node on Windows somehwat significantly I figured it would be useful to have a way to track this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.libuvIssues and PRs related to the libuv dependency or the uv binding.readlineIssues and PRs related to the built-in readline module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions