Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


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

Satyam opened this Issue · 4 comments

3 participants

Daniel Barreiro David Dias Jim Lloyd
Daniel Barreiro

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.

David Dias

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

Daniel Barreiro

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.

David Dias

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

David Dias diasdavid closed this
Jim Lloyd

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
Something went wrong with that request. Please try again.