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

Deprecation warning for listening on Db class events #7345

Closed
3 of 6 tasks
Moumouls opened this issue Apr 14, 2021 · 12 comments
Closed
3 of 6 tasks

Deprecation warning for listening on Db class events #7345

Moumouls opened this issue Apr 14, 2021 · 12 comments
Labels
bounty:$5 Bounty applies for fixing this issue (Parse Bounty Program) type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@Moumouls
Copy link
Member

Moumouls commented Apr 14, 2021

New Issue Checklist

Issue Description

Lot of warning from mongodb package after upgrade from #7322

Steps to reproduce

Install parse from master
Run parse server

At each server start parse server log.

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

Actual Outcome

Too many logs from mongodb pkg

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

Expected Outcome

No logs

Failing Test Case / Pull Request

  • 🤩 I submitted a PR with a fix and a test case.
  • 🧐 I submitted a PR with a failing test case.

Environment

Server

  • Parse Server version: current master
  • Operating system: macOS
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): local

Database

  • System (MongoDB or Postgres): Mongo
  • Database version: 4.4.X
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): local

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): none
  • SDK version: node

Logs

@Moumouls
Copy link
Member Author

downgrade to mongo 3.6.3 fix the issue, but it's just a temporary fix. I do not know which Parse Server code use DB listening events. @dplewis @mtrezza if you have an idea 🙂

@mtrezza
Copy link
Member

mtrezza commented Apr 14, 2021

Thanks for reporting!

Can you please fill out the versions in the template so we know in what environment (Node / MongoDB driver) you are experiencing this issue?

This deprecation warning comes from Node, not from the MongoDB driver?

@mtrezza mtrezza changed the title Mongo (node:13319) DeprecationWarning: Listening to events on the Db class has been deprecated and will be removed in the next major version. Deprecation warning for listening on Db class events Apr 14, 2021
@Moumouls
Copy link
Member Author

@mtrezza it seems to come from the native mongo driver: https://stackoverflow.com/questions/66190532/deprecationwarning-listening-to-events-on-the-db-class-has-been-deprecated-and

All version >3.6.3 seems to raise this log.

@mtrezza
Copy link
Member

mtrezza commented Apr 14, 2021

Thanks for the details, this seems to explain the fix needed:

Db is no longer the place to listen to events, you should listen to your MongoClient instead like so:

const client = new MongoClient(…)
client.on(‘Event name I want to listen too’, () => {…})
await client.connect()

The reason for this style is because by registering your listeners before connecting you can be sure that you’re able to capture every event that is triggered

A search in the Parse Server code base should reveal the places where listening to DB has to be changed.

@mtrezza mtrezza added type:bug Impaired feature or lacking behavior that is likely assumed S4 and removed needs more info labels Apr 14, 2021
@mtrezza
Copy link
Member

mtrezza commented Apr 14, 2021

I classified this as bug with severity S4 (small/trivial):

  • Using deprecated APIs should be avoided, therefore it is considered a bug
  • Because it is only a warning without any current functional effects, it is only considered a small / trivial bug

@mtrezza mtrezza added the bounty:$5 Bounty applies for fixing this issue (Parse Bounty Program) label Oct 5, 2021
@rocxteady
Copy link

Wasn't this fixed with: #7626? Why is it open still?

@mtrezza
Copy link
Member

mtrezza commented Dec 18, 2021

@Moumouls can you confirm this was fixed? #7626 does not reference this issue, but it also says that there are no more deprecation warnings, so I want to make sure.

@mtrezza mtrezza reopened this Dec 18, 2021
@rocxteady
Copy link

I did not pull and try with master branch but with the same changes I get no depreciation warnings in an example project.

@mtrezza
Copy link
Member

mtrezza commented Dec 18, 2021

I assume we can close this then, thanks for the heads up.

@mtrezza mtrezza closed this as completed Dec 18, 2021
@rocxteady
Copy link

You're welcome. Thank you for the good work.

@Moumouls
Copy link
Member Author

hi @mtrezza technically we are okay now about warnings :)

@mtrezza
Copy link
Member

mtrezza commented Dec 19, 2021

Nice, thanks @Moumouls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty:$5 Bounty applies for fixing this issue (Parse Bounty Program) type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

3 participants