.addOption(DBQuery.Option.noTimeout) available in meteor?

is .addOption(DBQuery.Option.noTimeout) available in meteor?

I’ve not found any references to the cursor.addOption() method (I assume that’s what you’re referring to?) in the nodejs driver for MongoDB, so I assume no.

The official documentation is a little confusing as well. There seems to be circular reference which says this has been deprecated in the Mongo shell and to use the available cursor methods. The listed method loops right back to the deprecation notice.


In any event, it seems as if this is/was a shell-only method.

1 Like

You’re right.

I am giving Collection.find({},{timeout: false}); a try…

I’m forEaching over a 5M document collection and it keeps timing out

MongoError: Cursor not found, cursor id: 271609685708
2016-12-21 00:39:52-05:00 at Object.Future.wait (/app/bundle/programs/server/node_modules/fibers/future.js:449:15)
2016-12-21 00:39:52-05:00 at SynchronousCursor._nextObject (packages/mongo/mongo_driver.js:1024:47

I don’t think that’s the purpose of cursor.addOption(DBQuery.Option.noTimeout). The docs say it’s to prevent idle cursors timing out. If you’re iterating over a cursor, I don’t think that it’s idle. Have you looked at cursor.maxTimeMS() (which is available in the node driver)?

hi Rob, well, do I just set maxTimeMS to 1000*6000 or something?

It does seem to be a timeout issue… this isn’t meteor but similar:

this will be my next attempt:

let query = Collection.find({},{timeout:false).maxTimeMS(500000);
query.forEach(function(item){ ...

You may well be right - I’ve not come across this before, so I’m just guessing :slight_smile:

However, I don’t think maxTime will be available on the minimongo cursor, so you may have to do this at the raw level.

ahhhhhh, now I get this:

Error: Can't wait without a fiber

I can’t believe mongo makes running a simple update loop over a collection of 1M+ documents into a black art.

Are you doing this in a method? You could just write an async method and await each raw mongo function (used without callbacks, they all now return Promises).

I suppose I should ask why you need to do that (or at least do it in that way)? :wink: