mongoose icon indicating copy to clipboard operation
mongoose copied to clipboard

Cannot read property 'message' of undefined

Open DevJeffreyG opened this issue 7 years ago • 13 comments

Do you want to request a feature or report a bug? Bug

What is the current behavior? The console keeps saying an error and make my app to restart

If the current behavior is a bug, please provide the steps to reproduce. My app starts, eventually, my console keeps saying:

/rbd/pnpm-volume/2c61ee42-4a04-4a21-b074-65934d0afc88/node_modules/.registry.npmjs.org/mongodb-core/3.2.4/node_modules/mongodb-core/lib/error.js:22

        super(message.message || message.errmsg || message.$err || 'n/a');

                      ^


TypeError: Cannot read property 'message' of undefined

    at new MongoError (/rbd/pnpm-volume/2c61ee42-4a04-4a21-b074-65934d0afc88/node_modules/.registry.npmjs.org/mongodb-core/3.2.4/node_modules/mongodb-core/lib/error.js:22:23)

    at new MongoNetworkError (/rbd/pnpm-volume/2c61ee42-4a04-4a21-b074-65934d0afc88/node_modules/.registry.npmjs.org/mongodb-core/3.2.4/node_modules/mongodb-core/lib/error.js:60:5)

    at TLSSocket.err (/rbd/pnpm-volume/2c61ee42-4a04-4a21-b074-65934d0afc88/node_modules/.registry.npmjs.org/mongodb-core/3.2.4/node_modules/mongodb-core/lib/connection/connect.js:287:16)

    at Object.onceWrapper (events.js:313:30)

    at emitNone (events.js:106:13)

    at TLSSocket.emit (events.js:208:7)

    at TLSSocket.Socket._onTimeout (net.js:422:8)

    at ontimeout (timers.js:498:11)

    at tryOnTimeout (timers.js:323:5)

    at Timer.listOnTimeout (timers.js:290:5)

What is the expected behavior? No errors displayed

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.

  • Node.js: 8.11.3
  • Mongoose: ^5.5.7
  • MongoDB: 2.6.10

DevJeffreyG avatar May 12 '19 03:05 DevJeffreyG

There's some interested nuances to your setup. It looks like you're using SSL - do you have a self-hosted SSL instance or are you connecting to Atlas?

Also, what are you using to install Mongoose? The node_modules/.registry.npmjs.org/mongodb-core/3.2.4/node_modules path doesn't look quite like a vanilla npm install...

vkarpov15 avatar May 13 '19 00:05 vkarpov15

My app is hosted on glitch, I use the atlas connection. I think glitch uses a different way for using node. (pnpm I think)

My app was working fine, but one day started to fail, so don't know

DevJeffreyG avatar May 13 '19 00:05 DevJeffreyG

Same is happening with me and it started all of a sudden. I was able to fix it on the server by removing node_modules and installing again. However, it is not working in CircleCi, even if I clear the cache.

/home/ubuntu/xseed-backend/node_modules/mongoose/node_modules/mongodb-core/lib/error.js:22
        super(message.message || message.errmsg || message.$err || 'n/a');
                      ^

TypeError: Cannot read property 'message' of undefined
    at new MongoError (/home/ubuntu/xseed-backend/node_modules/mongoose/node_modules/mongodb-core/lib/error.js:22:23)
    at new MongoNetworkError (/home/ubuntu/xseed-backend/node_modules/mongoose/node_modules/mongodb-core/lib/error.js:60:5)
    at Socket.err (/home/ubuntu/xseed-backend/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connect.js:287:16)
    at Object.onceWrapper (events.js:313:30)
    at emitNone (events.js:106:13)
    at Socket.emit (events.js:208:7)
    at Socket._onTimeout (net.js:407:8)
    at ontimeout (timers.js:475:11)
    at tryOnTimeout (timers.js:310:5)
    at Timer.listOnTimeout (timers.js:270:5)

node: 8.4.0 mongo: 3.4.4 mongoose: 5.5.8

rajchourasia avatar May 14 '19 08:05 rajchourasia

Same issue with me too, I use following packages, Node: v11.0.0 mongoose: 5.5.8 mongodb: 3.2.4

mshanmu8 avatar May 14 '19 11:05 mshanmu8

Figured that it works fine in mongoose: 5.5.0. So I am using this build for now.

rajchourasia avatar May 15 '19 06:05 rajchourasia

Also getting this on:

Node: v10.15.3 mongoose: 5.5.8 mongodb: 3.2.6

Rolled back to 5.5.4 and that seemed to work.

dphrag avatar May 15 '19 17:05 dphrag

@vkarpov15 I guess this is an underlying library issue and is fixed but is not released yet.

Introduced by https://github.com/mongodb-js/mongodb-core/commit/380a3867fd585afc51d54b4fd32c42b08eeb5a66 (3.2.4) Fixed in https://github.com/mongodb-js/mongodb-core/commit/83e224be0727438697a2bae3b01af381ab6efe90 (not released yet 3.2.5)

Fonger avatar May 15 '19 19:05 Fonger

Now I can confirm, using mongoose 5.5.0 fixes it

DevJeffreyG avatar May 16 '19 02:05 DevJeffreyG

This fix in package.json works for us:

"resolutions": {
    "mongodb-core": "3.2.3"
}

ravihugo avatar May 17 '19 05:05 ravihugo

Is the issue fixed ? I got this error today while running a tutorial using mongodb on Mac . So , rolled back mongoose to 5.5.4 as suggested by @Fonger .

GaJain avatar May 19 '19 13:05 GaJain

I am seeing the issue with version 5.5.9 in an AWS Lambda environment.

JeffersonSchuler avatar May 20 '19 19:05 JeffersonSchuler

mongoose 5.5.10 has been released and the underlying library was updated in this version. Try upgrading to see if it works.

Fonger avatar May 20 '19 19:05 Fonger

This looks fixed for me. Thank you.

JeffersonSchuler avatar May 21 '19 04:05 JeffersonSchuler