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

chore: upgrade to mongodb driver 4.1.2 #10810

Merged
merged 2 commits into from
Oct 4, 2021
Merged

Conversation

orgads
Copy link
Contributor

@orgads orgads commented Sep 29, 2021

And support working with other minor versions.

Summary

If the including package has both mongoose and mongodb installed with different versions, it leads to errors on build.

Examples

myfile.ts(40,31): error TS2345: Argument of type 'import("node_modules/mongoose/node_modules/mongodb/mongodb").ChangeStream<any>' is not assignable to parameter of type 'import("node_modules/mongodb/mongodb").ChangeStream<any>'.
  The types of 'options.session.clientOptions.autoEncrypter' are incompatible between these types.

And support working with other minor versions.
@orgads
Copy link
Contributor Author

orgads commented Oct 4, 2021

ping

Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to use exactly 4.1.2, LGTM otherwise 👍

@vkarpov15 vkarpov15 merged commit e102688 into Automattic:master Oct 4, 2021
@vkarpov15 vkarpov15 added this to the 6.0.9 milestone Oct 4, 2021
@orgads orgads deleted the mongo-4.1.2 branch October 4, 2021 16:45
@orgads
Copy link
Contributor Author

orgads commented Oct 4, 2021

Why use an exact version? It will break on next mongodb upgrade. See my first comment.

@vkarpov15
Copy link
Collaborator

Because we've had quite a few cases where minor and/or patch releases of the MongoDB node driver break something in Mongoose, and we'd like to avoid the combinatorial explosion of having to figure out whether every 6.0.9+ version of Mongoose supports MongoDB 4.2.

"If the including package has both mongoose and mongodb installed with different versions, it leads to errors on build." <-- that's a feature, not a bug. Mixing and matching ObjectId instances, Decimal128 instances, etc. between incompatible versions of MongoDB and Mongoose is unsupported and likely to cause bugs.

@orgads
Copy link
Contributor Author

orgads commented Oct 4, 2021

"If the including package has both mongoose and mongodb installed with different versions, it leads to errors on build." <-- that's a feature, not a bug. Mixing and matching ObjectId instances, Decimal128 instances, etc. between incompatible versions of MongoDB and Mongoose is unsupported and likely to cause bugs.

I was referring to minor/patch releases, which are not supposed to break anything. But if you say from your experience that it does break, I'll take it.

@vkarpov15
Copy link
Collaborator

In theory minor/patch releases don't break anything, but Mongoose uses a very wide surface area of the MongoDB Node driver, so compatibility issues are not uncommon.

If you need a workaround, you can always just put "mongodb": "4.x" as a top-level dependency in your package.json, and npm should dedupe against what version of the MongoDB driver Mongoose uses.

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

Successfully merging this pull request may close these issues.

None yet

2 participants