Skip to content

Conversation

@thesmart
Copy link

I have a cursor stream piped to another stream of type BiStream.

var BiStream = require('base-stream').BiStream; var myStream = new BiStream(); myStream.setMiddleware(function(data, cb) { console.log(data._id, ++i); cb(null, data); }); cursor = collection.find({}); cursor.stream().pipe(myStream); 

This prints the document ids up until batchSize (10K in my case), and then begins to sputter to a halting stop. I found that if I go into BiStream and stop emitting drain events, everything proceeds normally through the entire collection.

From Node.js Stream docs:

The 'drain' event can happen at any time, regardless of whether or not stream.write() has previously returned false. 

Doesn't seem like drain should affect much, but it halts a CursorStream.

@christkv
Copy link
Contributor

Pull requests are only accepted with a testcase that reproduces the problem please see contributor guidelines

@thesmart
Copy link
Author

Ok, I'll pull from my own npm then. Thanks for taking a look.

@christkv
Copy link
Contributor

I'm not trying to be unappreciative, a test let's me verify the problem and
make sure the patch is not fixing the symptoms instead of a root problem in
the code.

Sent from my BlackBerry® PlayBook™
www.blackberry.com


From: "John Smart" notifications@github.com
To: "mongodb/node-mongodb-native" node-mongodb-native@noreply.github.com
CC: "Christian Amor Kvalheim" christkv@gmail.com
Sent: December 15, 2012 10:08 PM
Subject: Re: [node-mongodb-native] CursorStream.pipe(stream) halts with
event 'drain' (#807)

Ok, I'll pull from my own npm then. Thanks for taking a look.


Reply to this email directly or view it on
GitHubhttps://github.com//pull/807#issuecomment-11410429.

@thesmart
Copy link
Author

No worries. I'm lazy. :)

On Sat, Dec 15, 2012 at 1:31 PM, Christian Amor Kvalheim <
notifications@github.com> wrote:

I'm not trying to be unappreciative, a test let's me verify the problem
and
make sure the patch is not fixing the symptoms instead of a root problem
in
the code.

Sent from my BlackBerry® PlayBook™
www.blackberry.com


From: "John Smart" notifications@github.com
To: "mongodb/node-mongodb-native" <
node-mongodb-native@noreply.github.com>
CC: "Christian Amor Kvalheim" christkv@gmail.com
Sent: December 15, 2012 10:08 PM
Subject: Re: [node-mongodb-native] CursorStream.pipe(stream) halts with
event 'drain' (#807)

Ok, I'll pull from my own npm then. Thanks for taking a look.


Reply to this email directly or view it on
GitHub<
https://github.com/mongodb/node-mongodb-native/pull/807#issuecomment-11410429>.


Reply to this email directly or view it on GitHubhttps://github.com//pull/807#issuecomment-11410733.

@christkv
Copy link
Contributor

the first commit makes sense so it's been put in master

@christkv christkv closed this Dec 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants