Automattic / mongoose

MongoDB object modeling designed to work in an asynchronous environment.
https://mongoosejs.com
MIT License
26.96k stars 3.84k forks source link

self.isDead is not a function #3224

Closed PhilippKrone closed 9 years ago

PhilippKrone commented 9 years ago

When using the option

replSet.connectWithNoPrimary

randomly the following error occurs:

error: uncaughtException: self.isDead is not a function date=Fri Jul 31 2015 09:02:05 GMT+0200 (CEST), pid=25875, uid=501, gid=20, cwd=/Users/philippkrone/Documents/startup/development/myProject-backend, execPath=/usr/local/bin/iojs, version=v2.2.1, argv=[/usr/local/bin/iojs, /Users/philippkrone/Documents/startup/development/myProject-backend/main.js], rss=106340352, heapTotal=76279040, heapUsed=32140824, loadavg=[1.9990234375, 1.880859375, 1.8447265625], uptime=128215, trace=[column=44, file=/Users/philippkrone/Documents/startup/development/myProject-backend/node_modules/mongoose/node_modules/mongodb/lib/cursor.js, function=Cursor.nextObject [as next], line=407, method=nextObject [as next], native=false, column=18, file=/Users/philippkrone/Documents/startup/development/myProject-backend/node_modules/mongoose/node_modules/mongodb/lib/topology_base.js, function=Store.execute, line=71, method=execute, native=false, column=31, file=/Users/philippkrone/Documents/startup/development/myProject-backend/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/replset.js, function=null._onTimeout, line=888, method=_onTimeout, native=false, column=15, file=timers.js, function=Timer.listOnTimeout, line=89, method=listOnTimeout, native=false], stack=[TypeError: self.isDead is not a function,     at Cursor.nextObject [as next]

Up to now, I was not able to figure out any specific reason, but it happens only if the above mentioned option is set. However, there seems to be no connection to whether there is actually a primary available or not.

vkarpov15 commented 9 years ago

Hmm can you confirm which version of mongoose you're using? Can't quite find the corresponding line in the mongodb node driver.

PhilippKrone commented 9 years ago

@vkarpov15 I think its not directly in mongoose but in mongodb itself:

node_modules/mongoose/node_modules/mongodb/lib/cursor.js:

https://github.com/mongodb/node-mongodb-native/blob/a7e165900a890e683bc889f620aedf361e50183d/lib/cursor.js

mansona commented 9 years ago

I just ran across this same issue when trying to connect to a Mongo cluster set up by Google Cloud Platform. Is there something that I can do to get around this issue? Downgrade a version or something?

mansona commented 9 years ago

I went into my installed mongoose in node_modules and upgraded from mongodb@2.0.40 to mongodb@2.0.42 and it seems to have fixed it.

I don't know what the solution for this would be, maybe release a bugfix for mongoose that requires a minimum of mongodb@2.0.24?

vkarpov15 commented 9 years ago

@PhilippKrone Yeah but telling me the exact version of mongoose also tells me the exact versions of the mongodb driver and mongodb-core, which makes debugging much easier :)

PhilippKrone commented 9 years ago

Sure, there we go:

"name": "mongoose", "description": "Mongoose MongoDB ODM", "version": "4.1.1-pre", "homepage": "http://mongoosejs.com", "browser": "lib/browser.js", "gitHead": "97424bbe687f643280946ef1d8738c2dbe006a00", "_id": "mongoose@4.1.1-pre", "_shasum": "c019132f96bb72343292082cef7c98c299d148e7", "_from": "git+https://github.com/Automattic/mongoose", "_resolved": "git+https://github.com/Automattic/mongoose#97424bbe687f643280946ef1d8738c2dbe006a00"

On 25 Aug 2015, at 18:18, Valeri Karpov notifications@github.com wrote:

@PhilippKrone https://github.com/PhilippKrone Yeah but telling me the exact version of mongoose also tells me the exact versions of the mongodb driver and mongodb-core, which makes debugging much easier :)

— Reply to this email directly or view it on GitHub https://github.com/Automattic/mongoose/issues/3224#issuecomment-134657289.

mansona commented 9 years ago

I'm getting this issue with these versions of mongoose & mongodb :

│ ├─┬ mongoose@4.1.3
│ │ ├── async@0.9.0
│ │ ├── bson@0.4.11
│ │ ├── hooks-fixed@1.1.0
│ │ ├── kareem@1.0.1
│ │ ├─┬ mongodb@2.0.40
│ │ │ ├── es6-promise@2.1.1
│ │ │ ├─┬ mongodb-core@1.2.9
│ │ │ │ └─┬ kerberos@0.0.12
│ │ │ │   └── nan@1.8.4
│ │ │ └─┬ readable-stream@1.0.31
│ │ │   ├── core-util-is@1.0.1
│ │ │   ├── inherits@2.0.1
│ │ │   ├── isarray@0.0.1
│ │ │   └── string_decoder@0.10.31
vkarpov15 commented 9 years ago

So we upgraded the node driver, according to @PhilippKrone this should work. I haven't been able to reproduce this issue though... @mansona do you have any ideas on how to reproduce this?

mansona commented 9 years ago

@vkarpov15 unfortunately i don't know how to bring this on, All I know is that i was connecting to a mongo cluster with 2 nodes and an arbiter and it would randomly happen. manually going into mongoose node_modules folder and updating mongodb to mongo@2.0.42 would solve it to me so this should fix my issues