Skip to content

Commit 2bc8640

Browse files
committed
Fix recursive readPref
When using discriminators, `readPref` is called for each schema which causes an incorrectly nested read preference (e.g., `{"_type":"ReadPreference","mode":{"_type":"ReadPreference","mode":{"_type":"ReadPreference","mode":{"_type":"ReadPreference","mode":"secondaryPreferred"}}}}`). This will ensure that if the `read` key is already a `ReadPref` object that we do not wrap it again.
1 parent 117fefd commit 2bc8640

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/utils.js

+4
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,10 @@ exports.readPref = function readPref (pref, tags) {
472472
pref = pref[0];
473473
}
474474

475+
if (pref instanceof ReadPref) {
476+
return pref;
477+
}
478+
475479
switch (pref) {
476480
case 'p':
477481
pref = 'primary';

0 commit comments

Comments
 (0)