parse-community / parse-server

Parse Server for Node.js / Express
https://parseplatform.org
Apache License 2.0
20.9k stars 4.78k forks source link

Deprecation warning for listening on Db class events #7345

Closed Moumouls closed 2 years ago

Moumouls commented 3 years ago

New Issue Checklist

Issue Description

Lot of warning from mongodb package after upgrade from https://github.com/parse-community/parse-server/pull/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

Environment

Server

Database

Client

Logs

Moumouls commented 3 years ago

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 commented 3 years ago

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?

Moumouls commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

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

rocxteady commented 2 years ago

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

mtrezza commented 2 years ago

@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.

rocxteady commented 2 years ago

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

mtrezza commented 2 years ago

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

rocxteady commented 2 years ago

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

Moumouls commented 2 years ago

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

mtrezza commented 2 years ago

Nice, thanks @Moumouls