Skip to content

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

Open

Description

@kasmanth

I got some deprecation warning

OS : macOS 11.2 Big Sur
Monk : Latest 7.3.3
Mongodb : Latest 3.6.4

(node:58674) DeprecationWarning: Listening to events on the Db class has been deprecated and will be removed in the next major version.
    at /Users/forte/Workspace/freejs/node_modules/monk/lib/manager.js:150:18
    at Array.forEach (<anonymous>)
    at Manager.<anonymous> (/Users/forte/Workspace/freejs/node_modules/monk/lib/manager.js:149:95)
    at /Users/forte/Workspace/freejs/node_modules/mongodb/lib/utils.js:693:5
    at /Users/forte/Workspace/freejs/node_modules/mongodb/lib/mongo_client.js:227:7
    at connectCallback (/Users/forte/Workspace/freejs/node_modules/mongodb/lib/operations/connect.js:366:5)
    at /Users/forte/Workspace/freejs/node_modules/mongodb/lib/operations/connect.js:602:5
    at Object.connectHandler [as callback] (/Users/forte/Workspace/freejs/node_modules/mongodb/lib/core/sdam/topology.js:297:43)
    at processWaitQueue (/Users/forte/Workspace/freejs/node_modules/mongodb/lib/core/sdam/topology.js:1048:21)
    at NativeTopology.serverUpdateHandler (/Users/forte/Workspace/freejs/node_modules/mongodb/lib/core/sdam/topology.js:567:7)
    at Server.emit (events.js:315:20)
    at Server.EventEmitter.emit (domain.js:467:12)
    at Monitor.<anonymous> (/Users/forte/Workspace/freejs/node_modules/mongodb/lib/core/sdam/server.js:151:12)
    at Monitor.emit (events.js:327:22)
    at Monitor.EventEmitter.emit (domain.js:467:12)
    at /Users/forte/Workspace/freejs/node_modules/mongodb/lib/core/sdam/monitor.js:272:13

Activity

  1. mcasto commented on Feb 18, 2021

    @mcasto

    Prompted to come here for this same issue.

  2. cutratefuture commented on Feb 19, 2021

    @cutratefuture

    https://stackoverflow.com/questions/66190532/deprecationwarning-listening-to-events-on-the-db-class-has-been-deprecated-and

    TEMP Fix.
    you must remove current mongoose version (I was on 5.11.13), and downgrade to mongoose@5.11.15, to resolve it.

  3. zkldi commented on Apr 13, 2021

    @zkldi

    This is fixed with mongodb version 3.6.5.

    npm i mongodb@3.6.5
    

    This can also be fixed with npm i mongodb@3.6.3, as that version is before the bug occured.

    Given that this isn't an issue with monk and is resolved downstream, this is probably safe to close?

  4. kasmanth commented on Apr 13, 2021

    @kasmanth
    Author

    I have tried to install mongodb@3.6.5 and 3.6.6 but the deprecation warning still be exist..
    And originally why I open the issue, I think this deprecation may cause problem in the next release if monk library is not patched / fixed

    And I have found monk library also have own mongodb version. So which mongodb version that we install to our project, monk will use its own mongodb version
    image

  5. zkldi commented on Apr 14, 2021

    @zkldi

    And I have found monk library also have own mongodb version. So which mongodb version that we install to our project, monk will use its own mongodb version

    This is not how NPM works.

    Monk specifies "mongodb": "^3.2.3",, which means any version of mongodb greater than or equal to 3.2.3, but NOT 4.x.x.

    This means that if you explicitly install a version of mongodb in your project, monk will use that version of mongodb, provided that the version you install is after 3.2.3.

  6. kasmanth commented on Apr 15, 2021

    @kasmanth
    Author

    @zkldi
    Please check it out this simple repo https://github.com/fortezhuo/monk_dummy
    The repo only contains mongodb 3.6.3 and monk 7.3.3

    {
      "name": "monk_dummy",
      "version": "1.0.0",
      "main": "index.js",
      "license": "MIT",
      "dependencies": {
        "mongodb": "3.6.3",
        "monk": "^7.3.3"
      }
    }
    

    image

    I used to use yarn and found monk still use mongodb@3.6.6. I think the problem may be caused by yarn.

    Yarn Version : 1.22.10

  7. zkldi commented on Apr 26, 2021

    @zkldi

    Strange, this has started breaking for me again. Nothing has changed with the versions installed, either.

  8. zkldi commented on Apr 26, 2021

    @zkldi

    Well, hm. Here's an uninteresting fix. If you:

    • install monk npm install monk
    • install mongodb@3.6.3, @3.6.5, or later deliberately npm install mongodb
    • uninstall monk npm uninstall monk
    • install monk npm install monk

    The errors do not appear. I have absolutely no idea how this fixes the problem, but uh, it does. Maybe NPM is doing some wacky cacheing.

  9. kasmanth commented on Apr 27, 2021

    @kasmanth
    Author

    I solved this problem with silly solution, I had cloned monk library, downgrade mongodb to 3.6.3, and allow lib to be hosted on github. So I use the cloned monk on my project

    "monk": "fortezhuo/monk",
    
  10. JonasTheGamer commented on May 8, 2021

    @JonasTheGamer

    Well, hm. Here's an uninteresting fix. If you:

    • install monk npm install monk
    • install mongodb@3.6.3, @3.6.5, or later deliberately npm install mongodb
    • uninstall monk npm uninstall monk
    • install monk npm install monk

    The errors do not appear. I have absolutely no idea how this fixes the problem, but uh, it does. Maybe NPM is doing some wacky cacheing.

    Hi! I tried this but I'm still receiving the warning. I tried all other solutions above as well... Anyone who found a fix yet?

  11. FranciscoMendes10866 commented on Jun 25, 2021

    @FranciscoMendes10866

    I have exactly the same problem. Is there already a solution?

  12. JonasTheGamer commented on Jan 2, 2022

    @JonasTheGamer

    It's a shame that we have not received any reply from the developers of this framework, stating how to resolve this issue or at least letting us know they are working on it.

    It's a pain in the ass when you're debugging your program and all you see is that you're being spammed by these errors.

    Someone, please tell me how to disable these errors, I don't care if they're just ignored or if the code is fixed, I JUST DONT WANT TO SEE THEM. Thanks.

  13. RogthatSinatra commented on Apr 12, 2023

    @RogthatSinatra
    • npm install monk

    This worked for me. i almost collapsed fixing this bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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