Code reference: https://github.com/mongodb/mongo/commit/00d0c713618fce418d28f2684a02d5a4be645276#diff-eba92d06638901285413b27c9b274b6a74f1a5408138096809eeaa68702dc05c