This repository was archived by the owner on May 17, 2021. It is now read-only.
read preference fix without tons of package lock changes #286
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is #282 just without the many package-lock.json changes, since those probably have some unintended consequences in Compass.
Here's the copy pasted description from that one.
In 3.6.3 the driver updated how operations are run so that operations which have the aspect
WRITE_OPERATIONdefault to primary instead of using the connection's readPreference:mongodb/node-mongodb-native@ddcd03d
This PR updates our use of the
db.commandfunction which is one of those operations with the aspectWRITE_OPERATIONto explicitly pass the readPreference which the user set up in Compass. This makes it so we have the same behavior as before and previous direct connections to secondaries don't suddenly stop working.I think we could do a lot of cleanup here. I'm also not quite sure why we're using
db.commandfor listing databases instead ofdb.listDatabases. This should fix the issue though. We also shouldn't be reaching intodb.s.readPreference. I can create a tech debt ticket 🤔I'm not sure if anywhere else in our codebase we rely on
db.commandfollow the readPreference of the connection, so I'm looking into that.Connecting and looking at data in a secondary with a direct connection:
