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

collection.deleteMany() being called in a deprecated way, yielding a mongoDB Driver warning #422

Closed
hillct opened this issue Jun 9, 2021 · 6 comments

Comments

@hillct
Copy link
Contributor

hillct commented Jun 9, 2021

  • I'm submitting a ...
    [X ] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

  • When used with a modern MongoDB driver (version 3.6.8 in this case but newer as well) we see this deprecation warning:

  • [MONGODB DRIVER] Warning: Top-level use of w, wtimeout, j, and fsync is deprecated. Use writeConcern instead.
    at emitWarning (node_modules/mongodb/lib/utils.js:851:17)

  • The fault lies with top level use of w and j parameters in a deprecated way here:

    collection.deleteMany(removeQuery(), {
    ...this.options.writeOperationOptions,
    w: 0,
    j: false,
    }),

  • theoretically, there may be a way to introduce writeConcern via a constructor parameter passed into options.writeOperationOptions but I haven't been successful with that theoretical workaround so far, and it would just be a workaround anyway. The superior solution would be to call collection.deleteMany() in a non-deprecated way.

  • A review of he documentation https://docs.mongodb.com/manual/reference/write-concern/ suggests that seting the j parameter to true, would resolve the issue but I'm not sure which would be the optimal behavior for the particular session management goals of connect-mongo, nor am I a typeScript king of guy, so I leave it to the experts to determine the optimal parameter values here.

@mingchuno
Copy link
Collaborator

Thanks for your information. Related issue in here: loopbackio/loopback-connector-mongodb#616
I will take a look to see if any change is required since it is a deprecation warning only. Don't want to upgrade and break the others

@mingchuno
Copy link
Collaborator

mingchuno commented Jun 10, 2021

@borfig
Copy link

borfig commented Jun 13, 2021

@mingchuno no more waiting - PR has been merged.

@hillct
Copy link
Contributor Author

hillct commented Aug 15, 2021

hanks for getting hid fix in place. Because there isn't a new NPM package featuring this fix, I attempted to use it via the Git repo, but was stymied by a few issues including circular dependencies and unit test errors. I was able to address he dependencies and one type error as reported by eslint (part of he test stack) but was stymied by the unit est failures. Please refer to #428 for details

@mingchuno
Copy link
Collaborator

@hillct @borfig Please help take a look on the PR
#430

@mingchuno
Copy link
Collaborator

v4.5.0 has been release, please try out @hillct

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

No branches or pull requests

3 participants