Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

readline not resuming  #25360

Closed
Closed
@mucbuc

Description

@mucbuc

Adding a time delay breaks the sample app from https://nodejs.org/api/readline.html.

STR:

  1. enter 'a' and press return
  2. notice prompt takes a moment to appear
  3. repeat 1 and 2 until prompt doesn't reappear (this happens after less than a dozen tries)

Expected: Prompt should consistently show up slightly delayed.

OS: mac 10.9.5 64bit
node -v: v0.12.2

var readline = require('readline'),
    rl = readline.createInterface(process.stdin, process.stdout);

rl.setPrompt('OHAI> ');
rl.prompt();

rl.on('line', function(line) {
  switch(line.trim()) {
    case 'hello':
      console.log('world!');
      break;
    default:
      console.log('Say what? I might have heard `' + line.trim() + '`');
      break;
  }
  setTimeout( function() { rl.prompt(); }, 1000 ); // delay
}).on('close', function() {
  console.log('Have a great day!');
  process.exit(0);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions