8000 Keypress events may not be triggered on Windows if validate callback contains async actions · Issue #402 · terkelg/prompts · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip 8000 to content
Keypress events may not be triggered on Windows if validate callback contains async actions #402
Open
@nicky1038

Description

@nicky1038

Describe the bug

When showing promtps multiple times, if one of the prompt inputs is validated using async actions, keypresses on other prompts may be missed. Happens only on Windows.

To Reproduce

Steps to reproduce the behavior:

const fetch = require('node-fetch'); // use v2 that still supports CommonJS modules
const prompts = require('prompts');

const promptConfigs = [{
  message: 'Prompt 1',
  validate: async () => {
    await fetch('https://jsonplaceholder.typicode.com/posts');
    return true;
  }
}, {
  message: 'Prompt 2'
}, {
  message: 'Prompt 3'
}];

async function main() {
  for (const c of promptConfigs) {
    await prompts({
      type: 'text',
      ...c
    });
  }
}

main();

Actual behavior

On node 16.20.2: on "Prompt 3" no keypress events are triggered untill Enter key is pressed - then the input can be entered as usual; if you remove fetch call from validate callback then everything will work perfectly.

On node 20.6.1: on "Prompt 3", on the first key press, no keypress event is triggered. The second and all next keypresses will be handled correctly.

Also, I have a project which I cannot post here, there I have the behavior described for node 16.20.2 even when it is run on 20.6.1.

Expected behavior

All key presses should be handled correctly.

System

  • OS: Windows 10 Pro 22H2
  • Terminal: cmd, Poweshell
  • Node version: 16.20.2, 20.6.1

Additional context

It may be Node issue. I encountered similar issues in this repo, still there wasn't anything about validate callback there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0