From 91ba19efdc4713903584c6161cfdd7b91b0e61f9 Mon Sep 17 00:00:00 2001 From: Eric Adum Date: Thu, 25 Mar 2021 18:30:08 -0400 Subject: [PATCH] fix: ensure cursor readPreference is applied to find operations (#2751) --- lib/operations/find.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/operations/find.js b/lib/operations/find.js index 4cf697f5f5..97ecdb8d2b 100644 --- a/lib/operations/find.js +++ b/lib/operations/find.js @@ -20,6 +20,9 @@ class FindOperation extends OperationBase { // copied from `CommandOperationV2`, to be subclassed in the future this.server = server; + // updates readPreference if setReadPreference was called on the cursor + this.readPreference = ReadPreference.resolve(this, this.options); + if (typeof this.cmd.allowDiskUse !== 'undefined' && maxWireVersion(server) < 4) { callback(new MongoError('The `allowDiskUse` option is not supported on MongoDB < 3.2')); return;