I stumbled upon an issue with the readstreams sometimes not reading the whole file. I tracked it down to the 'hacked' pause implementation in readstream.js#L182. Bypassing the native driver pause() method sometimes causes the driver stream to emit an 'end' event before emitting the last chunk of data.
Replacing the implementation with stream.pause(); self.paused = stream.paused; seems to fix the problem but I don't know about side-effects - I guess the 'hack' is in there for a reason. Changing this also seems to improve the read performance to native levels as mentioned in issue #44
Is it critical to force the driver stream to pause like that?
I stumbled upon an issue with the readstreams sometimes not reading the whole file. I tracked it down to the 'hacked' pause implementation in readstream.js#L182. Bypassing the native driver
pause()
method sometimes causes the driver stream to emit an 'end' event before emitting the last chunk of data. Replacing the implementation withstream.pause(); self.paused = stream.paused;
seems to fix the problem but I don't know about side-effects - I guess the 'hack' is in there for a reason. Changing this also seems to improve the read performance to native levels as mentioned in issue #44 Is it critical to force the driver stream to pause like that?I created a small script at https://github.com/ceari/gridfs-issue to reproduce the issue. Thank you for your time!