Method pause() on ReadLine should pause 'line' events #3628

Satyam opened this Issue Jul 3, 2012 · 4 comments


None yet

3 participants

Satyam commented Jul 3, 2012

The pause() and resume() methods should not only affect the ReadStream but also the emission of 'line' events, which is what you want to actually pause since that is the whole point of using ReadLine. As it stands, when you pause the ReadLine instance, 'line' events keep on coming until the array of lines is emptied.

@Satyam , streams have changed meantime, could you confirm if this is still an issue? Thank you

Satyam commented Jan 22, 2014

I'm sorry, I don't even remember where or why I used that feature. That was two years ago and somehow I got by. Should I close this issue? As far as I am concerned, it is no longer an issue, not for me.

Thank you @Satyam , if you run on it again, please inform us, I'll close it for now.

@diasdavid diasdavid closed this Jan 22, 2014
jimlloyd commented Sep 8, 2014

I believe this issue still exists with node v0.10 (I am currently using v0.10.29).

The problem is that it doesn't seem possible to use either readline or repl to process one line at a time when input is piped from a file. To demonstrate the problem, use this slightly revised example from

#!/usr/bin/env node
'use strict';
var readline = require('readline'),
rl = readline.createInterface(process.stdin, process.stdout);
rl.setPrompt('OHAI> ');
rl.on('line', function(line) {
function onetime() {
switch(line.trim()) {
case 'hello':
console.log('Say what? I might have heard ' + line.trim() + '');
// setImmediate(onetime);
}).on('close', function() {
console.log('Have a great day!');

Run the above script redirecting a file to stdin. Then comment out the call to onetime() and uncomment the line immediately above it that defers the call to onetime to the next tick. Note that the call to rl.pause() did nothing to throttle the data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment