Home icon indicating copy to clipboard operation
Home copied to clipboard

Mongoose / MongoDB error (related to replica set maybe)?

Open krstffr opened this issue 7 years ago • 7 comments

Just installed glimpse and tried running it in a very simple application, which basically does a .find on some Mongoose model, and it throws the error below.

Update when looking deeper into this: This only occurs when I connect to a replica set hosted on MongoDB Atlas though, not when running a single mogod on my own computer.

Versions Mongoose: 4.9.9 Express: 4.15.2 Node: 6.10.3

TypeError: Cannot read property 'availableConnections' of undefined
    at Function.MongoDBInspector.GetConnectionInfoFromCursor (/APP_PATH/node_modules/@glimpse/glimpse-agent-node/release/inspectors/MongoDBInspector.js:537:40)
    at MongoDBInspector.readStartInspector (/APP_PATH/node_modules/@glimpse/glimpse-agent-node/release/inspectors/MongoDBInspector.js:461:51)
    at Object.listeners._a.(anonymous function) [as listener] (/APP_PATH/node_modules/@glimpse/glimpse-agent-node/release/inspectors/MongoDBInspector.js:144:23)
    at Tracing.publish (/APP_PATH/node_modules/@glimpse/glimpse-agent-node/release/tracing/Tracing.js:31:26)
    at MongoDBProxy.cursorStartReadProxyCallbackOrPromise (/APP_PATH/node_modules/@glimpse/glimpse-agent-node/release/tracing/module_instrumentors/MongoDBProxy.js:131:31)
    at Cursor.proxy [as toArray] (/APP_PATH/node_modules/@glimpse/glimpse-agent-node/release/tracing/module_instrumentors/MongoDBProxy.js:63:40)
    at /APP_PATH/node_modules/mquery/lib/collection/node.js:29:12
    at handleCallback (/APP_PATH/node_modules/mongodb/lib/utils.js:120:56)
    at Collection.find (/APP_PATH/node_modules/mongodb/lib/collection.js:385:44)
    at NativeCollection.(anonymous function) [as find] (/APP_PATH/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:126:28)
    at NodeCollection.find (/APP_PATH/node_modules/mquery/lib/collection/node.js:26:19)
    at Query.find (/APP_PATH/node_modules/mquery/lib/mquery.js:1730:20)
    at Query._find (/APP_PATH/node_modules/mongoose/lib/query.js:1135:26)
    at /APP_PATH/node_modules/kareem/index.js:257:8
    at /APP_PATH/node_modules/kareem/index.js:23:7
    at wrappedCallback (/APP_PATH/node_modules/@glimpse/glimpse-agent-node/release/async-track/async-track.js:293:33)

krstffr avatar May 15 '17 07:05 krstffr

We apologize for the bug you've found, and thank you for the error report!

We'll get this fixed and a patch release out as soon as possible.

To aide in our efforts to reproduce this, can you verify the version of the mongodb package installed by Mongoose for us?

On May 15, 2017, at 3:33 AM, Kristoffer Klintberg [email protected] wrote:

Just installed glimpse and tried running it in a very simple application, which basically does a .find on some Mongoose model, and it throws the error below.

Update when looking deeper into this: This only occurs when I connect to a replica set hosted on MongoDB Atlas though, not when running a single mogod on my own computer.

Versions Mongoose: 4.9.9 Express: 4.15.2 Node: 6.10.3

TypeError: Cannot read property 'availableConnections' of undefined at Function.MongoDBInspector.GetConnectionInfoFromCursor (/APP_PATH/node_modules/@glimpse/glimpse-agent-node/release/inspectors/MongoDBInspector.js:537:40) at MongoDBInspector.readStartInspector (/APP_PATH/node_modules/@glimpse/glimpse-agent-node/release/inspectors/MongoDBInspector.js:461:51) at Object.listeners._a.(anonymous function) [as listener] (/APP_PATH/node_modules/@glimpse/glimpse-agent-node/release/inspectors/MongoDBInspector.js:144:23) at Tracing.publish (/APP_PATH/node_modules/@glimpse/glimpse-agent-node/release/tracing/Tracing.js:31:26) at MongoDBProxy.cursorStartReadProxyCallbackOrPromise (/APP_PATH/node_modules/@glimpse/glimpse-agent-node/release/tracing/module_instrumentors/MongoDBProxy.js:131:31) at Cursor.proxy [as toArray] (/APP_PATH/node_modules/@glimpse/glimpse-agent-node/release/tracing/module_instrumentors/MongoDBProxy.js:63:40) at /APP_PATH/node_modules/mquery/lib/collection/node.js:29:12 at handleCallback (/APP_PATH/node_modules/mongodb/lib/utils.js:120:56) at Collection.find (/APP_PATH/node_modules/mongodb/lib/collection.js:385:44) at NativeCollection.(anonymous function) [as find] (/APP_PATH/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:126:28) at NodeCollection.find (/APP_PATH/node_modules/mquery/lib/collection/node.js:26:19) at Query.find (/APP_PATH/node_modules/mquery/lib/mquery.js:1730:20) at Query._find (/APP_PATH/node_modules/mongoose/lib/query.js:1135:26) at /APP_PATH/node_modules/kareem/index.js:257:8 at /APP_PATH/node_modules/kareem/index.js:23:7 at wrappedCallback (/APP_PATH/node_modules/@glimpse/glimpse-agent-node/release/async-track/async-track.js:293:33) — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

nikmd23 avatar May 15 '17 11:05 nikmd23

From my yarn.lock file:

[email protected]:
  version "2.1.10"
  resolved "https://registry.yarnpkg.com/mongodb-core/-/mongodb-core-2.1.10.tgz#eb290681d196d3346a492161aa2ea0905e63151b"
  dependencies:
    bson "~1.0.4"
    require_optional "~1.0.0"

[email protected]:
  version "2.2.26"
  resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-2.2.26.tgz#1bd50c557c277c98e1a05da38c9839c4922b034a"
  dependencies:
    es6-promise "3.2.1"
    mongodb-core "2.1.10"
    readable-stream "2.2.7"

mongoose@^4.9.3:
  version "4.9.9"
  resolved "https://registry.yarnpkg.com/mongoose/-/mongoose-4.9.9.tgz#8671fbe06c945f55fba7ad03797bc02f19516762"
  dependencies:
    async "2.1.4"
    bson "~1.0.4"
    hooks-fixed "2.0.0"
    kareem "1.4.1"
    mongodb "2.2.26"
    mpath "0.2.1"
    mpromise "0.5.5"
    mquery "2.3.0"
    ms "0.7.2"
    muri "1.2.1"
    regexp-clone "0.0.1"
    sliced "1.0.1"```

krstffr avatar May 15 '17 11:05 krstffr

Thanks for reporting this @krstffr. Any chance you can get us a small project that reproduces the issue? I'll take a quick look at our logic. I thought our mongo DB instrumentation was turned off at the moment...

mike-kaufman avatar May 15 '17 15:05 mike-kaufman

Hi @mike-kaufman, the problem though is that it works when using my local DB, but not when I'm using the MongoDB Atlas one, so I might be able to set up this testv app for you if you yourselves are willing to set up an Atlas DB account etc since I unfortunately can't lend you mine?

krstffr avatar May 16 '17 06:05 krstffr

Thanks @krstffr. I'll see if I can set up an atlas DB & repro this...

mike-kaufman avatar May 16 '17 19:05 mike-kaufman

Cool @mike-kaufman, thanks a lot!

krstffr avatar May 17 '17 06:05 krstffr

Got the same error too with compose.io (db got replica) using https://github.com/Automattic/monk.

azappa avatar May 18 '17 06:05 azappa