Skip to content

DeprecationWarning: Listening to events on the Db class has been deprecated and will be removed in the next major version #9930

@Systerr

Description

@Systerr

Do you want to request a feature or report a bug?
bug (deprecation warning)

What is the current behavior?
On start we have deprecation warning into console

If the current behavior is a bug, please provide the steps to reproduce.

(node:9455) DeprecationWarning: Listening to events on the Db class has been deprecated and will be removed in the next major version.
    at _setClient (node_modules/mongoose/lib/connection.js:943:6)
    at node_modules/mongoose/lib/connection.js:839:7
    at node_modules/mongodb/lib/utils.js:693:5
    at node_modules/mongodb/lib/mongo_client.js:227:7
    at connectCallback (node_modules/mongodb/lib/operations/connect.js:366:5)
    at node_modules/mongodb/lib/operations/connect.js:602:5
    at Object.connectHandler [as callback] (/node_modules/mongodb/lib/core/sdam/topology.js:297:43)
    at processWaitQueue (node_modules/mongodb/lib/core/sdam/topology.js:1048:21)
    at NativeTopology.serverUpdateHandler (node_modules/mongodb/lib/core/sdam/topology.js:567:7)
    at Server.emit (events.js:315:20)

What is the expected behavior?
No deprecation warning
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Latest 5.11.16

I digged in into warning and found why this happens:

  1. This introduced into mongo driver on version v3.6.4 refactor: deprecate Db.on and Db.once mongodb/node-mongodb-native#2610 as part on preparation of driver v4 release
  2. Latest mongoose 5.11.16 introduced mongo drive update Upgrade mongodb driver to 3.6.4 #9893
  3. Original change happens because of refactor(db)!: suppress Db events mongodb/node-mongodb-native#2251

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions