Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fortezhuo opened this issue Feb 6, 2021 · 14 comments

Comments

@fortezhuo
Copy link

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
@mcasto
Copy link

mcasto commented Feb 18, 2021

Prompted to come here for this same issue.

@cutratefuture
Copy link

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 [email protected], to resolve it.

@zkrising
Copy link
Contributor

zkrising commented Apr 13, 2021

This is fixed with mongodb version 3.6.5.

This can also be fixed with npm i [email protected], 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?

@fortezhuo
Copy link
Author

fortezhuo commented Apr 13, 2021

I have tried to install [email protected] 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

@zkrising
Copy link
Contributor

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.

@fortezhuo
Copy link
Author

fortezhuo commented Apr 15, 2021

@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 [email protected]. I think the problem may be caused by yarn.

Yarn Version : 1.22.10

@zkrising
Copy link
Contributor

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

@zkrising
Copy link
Contributor

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

  • install monk npm install monk
  • install [email protected], @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.

@fortezhuo
Copy link
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",

@JonasTheGamer
Copy link

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

  • install monk npm install monk
  • install [email protected], @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?

@FranciscoMendes10866
Copy link

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

@JonasTheGamer
Copy link

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.

@RogthatSinatra
Copy link

  • 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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants