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

readline not resuming #25360

Closed
mucbuc opened this issue May 21, 2015 · 2 comments
Closed

readline not resuming #25360

mucbuc opened this issue May 21, 2015 · 2 comments

Comments

@mucbuc
Copy link

mucbuc commented May 21, 2015

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);
});
@jasnell
Copy link
Member

jasnell commented May 26, 2015

This may be the same issue as seen here: #9310. @joyent/node-coreteam

@misterdjules
Copy link

@jasnell Confirmed duplicate of #9310 and tested that #25475 fixes it. Closing as such. Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants