question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 https://github.com/mongodb/node-mongodb-native/pull/2610 as part on preparation of driver v4 release
  2. Latest mongoose 5.11.16 introduced mongo drive update https://github.com/Automattic/mongoose/pull/9893
  3. Original change happens because of https://github.com/mongodb/node-mongodb-native/pull/2251

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:20
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
lantw44commented, Feb 24, 2021

The warning still exists in mongoose 5.11.18:

(node:90089) 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:932:10)
    at node_modules/mongoose/lib/connection.js:838: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 connectHandler (node_modules/mongodb/lib/core/sdam/topology.js:297:43)
    at cb (node_modules/mongodb/lib/core/sdam/topology.js:681:26)
    at node_modules/mongodb/lib/cmap/connection_pool.js:350:13
    at handleOperationResult (node_modules/mongodb/lib/core/sdam/server.js:558:5)
    at MessageStream.messageHandler (node_modules/mongodb/lib/cmap/connection.js:277:5)
    at MessageStream.emit (events.js:315:20)
    at MessageStream.EventEmitter.emit (domain.js:529:15)
    at processIncomingData (node_modules/mongodb/lib/cmap/message_stream.js:144:12)
    at MessageStream._write (node_modules/mongodb/lib/cmap/message_stream.js:42:5)
    at writeOrBuffer (internal/streams/writable.js:358:12)
9reactions
PurpShellcommented, Feb 17, 2021

how does this get fixed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Listening to events on the Db class has been deprecated and ...
(node:44612) DeprecationWarning: Listening to events on the Db class has been deprecated and will be removed in the next major version.
Read more >
Listening to events on the Db class has been deprecated and ...
(node:44612) DeprecationWarning: Listening to events on the Db class has been deprecated and will be removed in the next major version.
Read more >
Listening to events on the Db class has been deprecated and ...
I got some deprecation warning OS : macOS 11.2 Big Sur Monk : Latest 7.3.3 ... class has been deprecated and will be...
Read more >
Listening to events on the Db class has been deprecated and ...
Node.js – DeprecationWarning: Listening to events on the Db class has been deprecated and will be removed in the next major version.
Read more >
Mongoose v6.8.1: Deprecation Warnings
There are several deprecations in the MongoDB Node.js driver that Mongoose users should be aware of. Mongoose provides options to work around these ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found