aheckmann / gridfs-stream

Easily stream files to and from MongoDB
MIT License
615 stars 120 forks source link

Pause and resume don't work on a read stream #13

Closed Reggino closed 11 years ago

Reggino commented 11 years ago

Hi!

Thank you for your work on gridfs-stream. I found an issue while using the read-stream. When using pause(), no more data is coming from the stream. So the following code:

readStream = gfs.createReadStream('5139c756d4efb3741200006c');

console.log('Pausing stream');
readStream.pause();

setTimeout(function () {
    console.log('Resuming stream');
    readStream.resume();
}, 1000);

readStream.on('data', function () {
    console.log('Data');
});
readStream.on('end', function () {
    console.log('End');
});

Returns ouput:

Pausing stream
Resuming stream

And not the expected:

Pausing stream
Resuming stream
Data
End

Any advice is greatly appreciated!

Regards,

Tim

Reggino commented 11 years ago

Found the cause, please consider the supplied pull request

Reggino commented 11 years ago

@aheckmann could you please look into this? Thanks!

aheckmann commented 11 years ago

Sorry about the late response and thanks for the pull request + reminder. I'm pretty busy so I gave you commit access to make the changes you need. It would be really great if you added a test for this fix too.