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
Description
Adding a time delay breaks the sample app from https://nodejs.org/api/readline.html.
STR:
- enter 'a' and press return
- notice prompt takes a moment to appear
- 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
Labels
No labels