Skip to content

mongoose.createConnection TypeError: Cannot read property 'prepare' of undefined #10377

@speedtreammanga

Description

@speedtreammanga

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

What is the current behavior?
I'm getting this error:

/app/express/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connect.js:182
nodejs_1         |     authProvider.prepare(handshakeDoc, authContext, callback);
nodejs_1         |                  ^
nodejs_1         | TypeError: Cannot read property 'prepare' of undefined
nodejs_1         |     at prepareHandshakeDocument (/app/express/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connect.js:182:18)
nodejs_1         |     at performInitialHandshake (/app/express/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connect.js:87:3)
nodejs_1         |     at /app/express/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connect.js:36:5
nodejs_1         |     at callback (/app/express/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connect.js:280:5)
nodejs_1         |     at Socket.connectHandler (/app/express/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connect.js:325:5)
nodejs_1         |     at Object.onceWrapper (node:events:513:28)
nodejs_1         |     at Socket.emit (node:events:394:28)
nodejs_1         |     at Socket.emit (node:domain:470:12)
nodejs_1         |     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1119:10)

on this call: https://github.com/speedtreammanga/read-latte/blob/7947c7ef29667d681ffdc60dc377b7ab4781d15e/express/src/config/connection/connection.ts#L21

If the current behavior is a bug, please provide the steps to reproduce.
repo: https://github.com/speedtreammanga/read-latte
steps:

  • clone repo;
  • create a .env file at the root of the project with the environment variables used in my docker-compose file;
  • run cd <project root>;
  • run docker-compose build;
  • run docker-compose run;

My tsconfig.json file

What is the expected behavior?
mongoose should be able to connect to my mongodb without any issue.

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

Metadata

Metadata

Assignees

Labels

underlying library issueThis issue is a bug with an underlying library, like the MongoDB driver or mongodb-core

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions