Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency

Hi,

I am getting a warning consistently each time our webserver or another process connects to the DB.

(node:24990) Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency
    at emitCircularRequireWarning (internal/modules/cjs/loader.js:650:11)
    at Object.get (internal/modules/cjs/loader.js:664:5)
    at Object.<anonymous> (/home/my-user/my-project/node_modules/mongodb/lib/operations/operation.js:4:38)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at Module.Hook._require.Module.require (/usr/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:80:39)
    at require (internal/modules/cjs/helpers.js:88:18)

Some extra information:

  • The process that tries to connect is started via PM2
  • The connection is established and works, this is only a warning, not a crash
  • Driver mongodb for nodejs, version 3.6.2
  • It only happens on one of our environments. The only unique thing about this environment is that it connects to mongoDB using VPC peering (the others do not: they do not get this warning)
  • The server is hosted on an AWS EC2, and we use MongoDB Atlas hosted on AWS as cloud provider as well

I googled for this error and encountered similar errors. Those were solved by Mongodb in a newer version of the driver. So it seems to me this is also an issue with the driver itself, and not our code.

Thanks in advance.

4 Likes

Can confirm this error also appears in node mongodb v3.6.4 but not v3.6.3

2 Likes

Hi Goran !
For me, appears in mongodb v3.6.4

(node:32197) Warning: Accessing non-existent property ‘MongoError’ of module exports inside circular dependency
(Use node --trace-warnings ... to show where the warning was created)

Thanks guys

4 Likes

Same error at 3.6.4 version

I’m using “connect-mongo”: “^3.2.0”, and “mongoose”: “^5.11.15”, node version v14.15.4 and I get

(node:26812) Warning: Accessing non-existent property ‘MongoError’ of module exports inside circular dependency
(Use node --trace-warnings ... to show where the warning was created)

3 Likes

Hi All,

Thanks for reporting! I hit the issue myself today while I was working. I checked in with the Node driver team. The warning is safe to ignore and will hopefully be gone in an upcoming release.

26 Likes

1 Like

Thank you for letting us know! I was worried for a bit to be honest and I kept googling to see what I was doing wrong, until I found this.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.