mongodb 4.0.0 → 4.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/README.md +62 -30
  2. package/lib/bson.js +1 -0
  3. package/lib/bson.js.map +1 -1
  4. package/lib/bulk/common.js +53 -30
  5. package/lib/bulk/common.js.map +1 -1
  6. package/lib/bulk/ordered.js +3 -2
  7. package/lib/bulk/ordered.js.map +1 -1
  8. package/lib/bulk/unordered.js +3 -2
  9. package/lib/bulk/unordered.js.map +1 -1
  10. package/lib/change_stream.js +23 -13
  11. package/lib/change_stream.js.map +1 -1
  12. package/lib/cmap/auth/auth_provider.js +2 -1
  13. package/lib/cmap/auth/auth_provider.js.map +1 -1
  14. package/lib/cmap/auth/gssapi.js +5 -4
  15. package/lib/cmap/auth/gssapi.js.map +1 -1
  16. package/lib/cmap/auth/mongo_credentials.js +9 -5
  17. package/lib/cmap/auth/mongo_credentials.js.map +1 -1
  18. package/lib/cmap/auth/mongocr.js +2 -2
  19. package/lib/cmap/auth/mongocr.js.map +1 -1
  20. package/lib/cmap/auth/mongodb_aws.js +32 -32
  21. package/lib/cmap/auth/mongodb_aws.js.map +1 -1
  22. package/lib/cmap/auth/plain.js +1 -1
  23. package/lib/cmap/auth/plain.js.map +1 -1
  24. package/lib/cmap/auth/scram.js +15 -12
  25. package/lib/cmap/auth/scram.js.map +1 -1
  26. package/lib/cmap/auth/x509.js +2 -2
  27. package/lib/cmap/auth/x509.js.map +1 -1
  28. package/lib/cmap/command_monitoring_events.js +26 -10
  29. package/lib/cmap/command_monitoring_events.js.map +1 -1
  30. package/lib/cmap/commands.js +9 -5
  31. package/lib/cmap/commands.js.map +1 -1
  32. package/lib/cmap/connect.js +23 -9
  33. package/lib/cmap/connect.js.map +1 -1
  34. package/lib/cmap/connection.js +43 -46
  35. package/lib/cmap/connection.js.map +1 -1
  36. package/lib/cmap/connection_pool.js +113 -15
  37. package/lib/cmap/connection_pool.js.map +1 -1
  38. package/lib/cmap/connection_pool_events.js +3 -1
  39. package/lib/cmap/connection_pool_events.js.map +1 -1
  40. package/lib/cmap/errors.js +3 -3
  41. package/lib/cmap/errors.js.map +1 -1
  42. package/lib/cmap/message_stream.js +1 -1
  43. package/lib/cmap/message_stream.js.map +1 -1
  44. package/lib/cmap/metrics.js +62 -0
  45. package/lib/cmap/metrics.js.map +1 -0
  46. package/lib/cmap/stream_description.js +3 -1
  47. package/lib/cmap/stream_description.js.map +1 -1
  48. package/lib/cmap/wire_protocol/compression.js +22 -9
  49. package/lib/cmap/wire_protocol/compression.js.map +1 -1
  50. package/lib/cmap/wire_protocol/shared.js +1 -1
  51. package/lib/cmap/wire_protocol/shared.js.map +1 -1
  52. package/lib/collection.js +23 -18
  53. package/lib/collection.js.map +1 -1
  54. package/lib/connection_string.js +76 -30
  55. package/lib/connection_string.js.map +1 -1
  56. package/lib/cursor/abstract_cursor.js +75 -68
  57. package/lib/cursor/abstract_cursor.js.map +1 -1
  58. package/lib/cursor/aggregation_cursor.js +47 -9
  59. package/lib/cursor/aggregation_cursor.js.map +1 -1
  60. package/lib/cursor/find_cursor.js +53 -13
  61. package/lib/cursor/find_cursor.js.map +1 -1
  62. package/lib/db.js +21 -14
  63. package/lib/db.js.map +1 -1
  64. package/lib/deps.js +16 -5
  65. package/lib/deps.js.map +1 -1
  66. package/lib/encrypter.js +5 -8
  67. package/lib/encrypter.js.map +1 -1
  68. package/lib/error.js +230 -34
  69. package/lib/error.js.map +1 -1
  70. package/lib/explain.js +2 -2
  71. package/lib/explain.js.map +1 -1
  72. package/lib/gridfs/download.js +22 -47
  73. package/lib/gridfs/download.js.map +1 -1
  74. package/lib/gridfs/index.js +4 -3
  75. package/lib/gridfs/index.js.map +1 -1
  76. package/lib/gridfs/upload.js +13 -21
  77. package/lib/gridfs/upload.js.map +1 -1
  78. package/lib/index.js +27 -2
  79. package/lib/index.js.map +1 -1
  80. package/lib/logger.js +3 -2
  81. package/lib/logger.js.map +1 -1
  82. package/lib/mongo_client.js +5 -8
  83. package/lib/mongo_client.js.map +1 -1
  84. package/lib/mongo_types.js.map +1 -1
  85. package/lib/operations/add_user.js +2 -3
  86. package/lib/operations/add_user.js.map +1 -1
  87. package/lib/operations/aggregate.js +12 -9
  88. package/lib/operations/aggregate.js.map +1 -1
  89. package/lib/operations/command.js +5 -7
  90. package/lib/operations/command.js.map +1 -1
  91. package/lib/operations/common_functions.js +1 -1
  92. package/lib/operations/common_functions.js.map +1 -1
  93. package/lib/operations/connect.js +3 -2
  94. package/lib/operations/connect.js.map +1 -1
  95. package/lib/operations/count.js +1 -1
  96. package/lib/operations/count.js.map +1 -1
  97. package/lib/operations/count_documents.js +1 -1
  98. package/lib/operations/count_documents.js.map +1 -1
  99. package/lib/operations/delete.js +5 -5
  100. package/lib/operations/delete.js.map +1 -1
  101. package/lib/operations/distinct.js +2 -2
  102. package/lib/operations/distinct.js.map +1 -1
  103. package/lib/operations/estimated_document_count.js +5 -1
  104. package/lib/operations/estimated_document_count.js.map +1 -1
  105. package/lib/operations/eval.js.map +1 -1
  106. package/lib/operations/execute_operation.js +31 -17
  107. package/lib/operations/execute_operation.js.map +1 -1
  108. package/lib/operations/find.js +13 -9
  109. package/lib/operations/find.js.map +1 -1
  110. package/lib/operations/find_and_modify.js +9 -9
  111. package/lib/operations/find_and_modify.js.map +1 -1
  112. package/lib/operations/indexes.js +8 -3
  113. package/lib/operations/indexes.js.map +1 -1
  114. package/lib/operations/insert.js +5 -3
  115. package/lib/operations/insert.js.map +1 -1
  116. package/lib/operations/is_capped.js +2 -1
  117. package/lib/operations/is_capped.js.map +1 -1
  118. package/lib/operations/list_collections.js +6 -3
  119. package/lib/operations/list_collections.js.map +1 -1
  120. package/lib/operations/map_reduce.js +1 -1
  121. package/lib/operations/map_reduce.js.map +1 -1
  122. package/lib/operations/operation.js +3 -1
  123. package/lib/operations/operation.js.map +1 -1
  124. package/lib/operations/options_operation.js +2 -1
  125. package/lib/operations/options_operation.js.map +1 -1
  126. package/lib/operations/profiling_level.js +4 -2
  127. package/lib/operations/profiling_level.js.map +1 -1
  128. package/lib/operations/set_profiling_level.js +4 -2
  129. package/lib/operations/set_profiling_level.js.map +1 -1
  130. package/lib/operations/update.js +12 -12
  131. package/lib/operations/update.js.map +1 -1
  132. package/lib/operations/validate_collection.js +6 -5
  133. package/lib/operations/validate_collection.js.map +1 -1
  134. package/lib/promise_provider.js +1 -1
  135. package/lib/promise_provider.js.map +1 -1
  136. package/lib/read_preference.js +8 -8
  137. package/lib/read_preference.js.map +1 -1
  138. package/lib/sdam/common.js +12 -10
  139. package/lib/sdam/common.js.map +1 -1
  140. package/lib/sdam/server.js +90 -25
  141. package/lib/sdam/server.js.map +1 -1
  142. package/lib/sdam/server_description.js +9 -4
  143. package/lib/sdam/server_description.js.map +1 -1
  144. package/lib/sdam/server_selection.js +10 -4
  145. package/lib/sdam/server_selection.js.map +1 -1
  146. package/lib/sdam/srv_polling.js +1 -1
  147. package/lib/sdam/srv_polling.js.map +1 -1
  148. package/lib/sdam/topology.js +42 -21
  149. package/lib/sdam/topology.js.map +1 -1
  150. package/lib/sdam/topology_description.js +7 -3
  151. package/lib/sdam/topology_description.js.map +1 -1
  152. package/lib/sessions.js +132 -31
  153. package/lib/sessions.js.map +1 -1
  154. package/lib/sort.js +3 -3
  155. package/lib/sort.js.map +1 -1
  156. package/lib/transactions.js +15 -7
  157. package/lib/transactions.js.map +1 -1
  158. package/lib/utils.js +60 -20
  159. package/lib/utils.js.map +1 -1
  160. package/mongodb.d.ts +523 -138
  161. package/mongodb.ts34.d.ts +480 -141
  162. package/package.json +44 -48
  163. package/src/bson.ts +1 -0
  164. package/src/bulk/common.ts +83 -43
  165. package/src/bulk/ordered.ts +4 -3
  166. package/src/bulk/unordered.ts +4 -3
  167. package/src/change_stream.ts +46 -29
  168. package/src/cmap/auth/auth_provider.ts +3 -2
  169. package/src/cmap/auth/gssapi.ts +15 -5
  170. package/src/cmap/auth/mongo_credentials.ts +22 -8
  171. package/src/cmap/auth/mongocr.ts +3 -3
  172. package/src/cmap/auth/mongodb_aws.ts +52 -39
  173. package/src/cmap/auth/plain.ts +2 -2
  174. package/src/cmap/auth/scram.ts +23 -13
  175. package/src/cmap/auth/x509.ts +3 -3
  176. package/src/cmap/command_monitoring_events.ts +36 -14
  177. package/src/cmap/commands.ts +12 -6
  178. package/src/cmap/connect.ts +42 -12
  179. package/src/cmap/connection.ts +54 -62
  180. package/src/cmap/connection_pool.ts +141 -20
  181. package/src/cmap/connection_pool_events.ts +8 -1
  182. package/src/cmap/errors.ts +3 -4
  183. package/src/cmap/message_stream.ts +2 -4
  184. package/src/cmap/metrics.ts +58 -0
  185. package/src/cmap/stream_description.ts +6 -1
  186. package/src/cmap/wire_protocol/compression.ts +26 -13
  187. package/src/cmap/wire_protocol/shared.ts +4 -2
  188. package/src/collection.ts +75 -70
  189. package/src/connection_string.ts +97 -34
  190. package/src/cursor/abstract_cursor.ts +141 -104
  191. package/src/cursor/aggregation_cursor.ts +34 -20
  192. package/src/cursor/find_cursor.ts +41 -21
  193. package/src/db.ts +19 -18
  194. package/src/deps.ts +110 -22
  195. package/src/encrypter.ts +6 -12
  196. package/src/error.ts +264 -48
  197. package/src/explain.ts +3 -3
  198. package/src/gridfs/download.ts +48 -53
  199. package/src/gridfs/index.ts +5 -4
  200. package/src/gridfs/upload.ts +32 -33
  201. package/src/index.ts +42 -4
  202. package/src/logger.ts +6 -3
  203. package/src/mongo_client.ts +20 -23
  204. package/src/mongo_types.ts +19 -20
  205. package/src/operations/add_user.ts +4 -5
  206. package/src/operations/aggregate.ts +18 -17
  207. package/src/operations/command.ts +7 -10
  208. package/src/operations/common_functions.ts +2 -3
  209. package/src/operations/connect.ts +4 -3
  210. package/src/operations/count.ts +2 -2
  211. package/src/operations/count_documents.ts +2 -2
  212. package/src/operations/delete.ts +8 -6
  213. package/src/operations/distinct.ts +5 -3
  214. package/src/operations/estimated_document_count.ts +5 -1
  215. package/src/operations/eval.ts +1 -1
  216. package/src/operations/execute_operation.ts +41 -20
  217. package/src/operations/find.ts +25 -16
  218. package/src/operations/find_and_modify.ts +12 -10
  219. package/src/operations/indexes.ts +39 -8
  220. package/src/operations/insert.ts +7 -4
  221. package/src/operations/is_capped.ts +3 -2
  222. package/src/operations/list_collections.ts +9 -6
  223. package/src/operations/map_reduce.ts +4 -2
  224. package/src/operations/operation.ts +7 -2
  225. package/src/operations/options_operation.ts +3 -2
  226. package/src/operations/profiling_level.ts +5 -3
  227. package/src/operations/set_profiling_level.ts +9 -3
  228. package/src/operations/update.ts +17 -13
  229. package/src/operations/validate_collection.ts +7 -6
  230. package/src/promise_provider.ts +2 -2
  231. package/src/read_preference.ts +11 -9
  232. package/src/sdam/common.ts +11 -9
  233. package/src/sdam/server.ts +168 -69
  234. package/src/sdam/server_description.ts +16 -4
  235. package/src/sdam/server_selection.ts +15 -7
  236. package/src/sdam/srv_polling.ts +2 -2
  237. package/src/sdam/topology.ts +67 -36
  238. package/src/sdam/topology_description.ts +11 -4
  239. package/src/sessions.ts +194 -37
  240. package/src/sort.ts +6 -4
  241. package/src/transactions.ts +18 -9
  242. package/src/utils.ts +73 -20
  243. package/HISTORY.md +0 -2993
  244. package/lib/operations/find_one.js +0 -34
  245. package/lib/operations/find_one.js.map +0 -1
  246. package/src/operations/find_one.ts +0 -43
@@ -11,7 +11,13 @@ import {
11
11
  } from '../sessions';
12
12
  import { SrvPoller, SrvPollingEvent } from './srv_polling';
13
13
  import { CMAP_EVENTS, ConnectionPoolEvents } from '../cmap/connection_pool';
14
- import { MongoServerSelectionError, MongoDriverError } from '../error';
14
+ import {
15
+ MongoServerSelectionError,
16
+ MongoCompatibilityError,
17
+ MongoDriverError,
18
+ MongoTopologyClosedError,
19
+ MongoRuntimeError
20
+ } from '../error';
15
21
  import { readPreferenceServerSelector, ServerSelector } from './server_selection';
16
22
  import {
17
23
  makeStateMachine,
@@ -28,7 +34,7 @@ import {
28
34
  ServerType,
29
35
  ClusterTime,
30
36
  TimerQueue,
31
- resolveClusterTime,
37
+ _advanceClusterTime,
32
38
  drainTimerQueue,
33
39
  clearAndRemoveTimerFrom,
34
40
  STATE_CLOSED,
@@ -146,6 +152,7 @@ export interface TopologyOptions extends BSONSerializeOptions, ServerOptions {
146
152
  srvPoller?: SrvPoller;
147
153
  /** Indicates that a client should directly connect to a node without attempting to discover its topology type */
148
154
  directConnection: boolean;
155
+ loadBalanced: boolean;
149
156
  metadata: ClientMetadata;
150
157
  /** MongoDB server API version */
151
158
  serverApi?: ServerApi;
@@ -248,6 +255,7 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
248
255
  retryWrites: DEFAULT_OPTIONS.get('retryWrites'),
249
256
  serverSelectionTimeoutMS: DEFAULT_OPTIONS.get('serverSelectionTimeoutMS'),
250
257
  directConnection: DEFAULT_OPTIONS.get('directConnection'),
258
+ loadBalanced: DEFAULT_OPTIONS.get('loadBalanced'),
251
259
  metadata: DEFAULT_OPTIONS.get('metadata'),
252
260
  monitorCommands: DEFAULT_OPTIONS.get('monitorCommands'),
253
261
  tls: DEFAULT_OPTIONS.get('tls'),
@@ -274,7 +282,8 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
274
282
  } else if (seed instanceof HostAddress) {
275
283
  seedlist.push(seed);
276
284
  } else {
277
- throw new MongoDriverError(`Topology cannot be constructed from ${JSON.stringify(seed)}`);
285
+ // FIXME(NODE-3483): May need to be a MongoParseError
286
+ throw new MongoRuntimeError(`Topology cannot be constructed from ${JSON.stringify(seed)}`);
278
287
  }
279
288
  }
280
289
 
@@ -325,7 +334,7 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
325
334
  detectSrvRecords: ev => this.detectSrvRecords(ev)
326
335
  };
327
336
 
328
- if (options.srvHost) {
337
+ if (options.srvHost && !options.loadBalanced) {
329
338
  this.s.srvPoller =
330
339
  options.srvPoller ??
331
340
  new SrvPoller({
@@ -379,6 +388,10 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
379
388
  return this.s.description;
380
389
  }
381
390
 
391
+ get loadBalanced(): boolean {
392
+ return this.s.options.loadBalanced;
393
+ }
394
+
382
395
  get capabilities(): ServerCapabilities {
383
396
  return new ServerCapabilities(this.lastIsMaster());
384
397
  }
@@ -411,7 +424,19 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
411
424
  );
412
425
 
413
426
  // connect all known servers, then attempt server selection to connect
414
- connectServers(this, Array.from(this.s.description.servers.values()));
427
+ const serverDescriptions = Array.from(this.s.description.servers.values());
428
+ connectServers(this, serverDescriptions);
429
+
430
+ // In load balancer mode we need to fake a server description getting
431
+ // emitted from the monitor, since the monitor doesn't exist.
432
+ if (this.s.options.loadBalanced) {
433
+ for (const description of serverDescriptions) {
434
+ const newDescription = new ServerDescription(description.hostAddress, undefined, {
435
+ loadBalanced: this.s.options.loadBalanced
436
+ });
437
+ this.serverUpdateHandler(newDescription);
438
+ }
439
+ }
415
440
 
416
441
  const readPreference = options.readPreference ?? ReadPreference.primary;
417
442
  this.selectServer(readPreferenceServerSelector(readPreference), options, (err, server) => {
@@ -472,7 +497,7 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
472
497
 
473
498
  stateTransition(this, STATE_CLOSING);
474
499
 
475
- drainWaitQueue(this[kWaitQueue], new MongoDriverError('Topology closed'));
500
+ drainWaitQueue(this[kWaitQueue], new MongoTopologyClosedError());
476
501
  drainTimerQueue(this.s.connectionTimers);
477
502
 
478
503
  if (this.s.srvPoller) {
@@ -482,28 +507,30 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
482
507
 
483
508
  this.removeListener(Topology.TOPOLOGY_DESCRIPTION_CHANGED, this.s.detectShardedTopology);
484
509
 
485
- for (const session of this.s.sessions) {
486
- session.endSession();
487
- }
488
-
489
- this.s.sessionPool.endAllPooledSessions(() => {
490
- eachAsync(
491
- Array.from(this.s.servers.values()),
492
- (server, cb) => destroyServer(server, this, options, cb),
493
- err => {
494
- this.s.servers.clear();
495
-
496
- // emit an event for close
497
- this.emit(Topology.TOPOLOGY_CLOSED, new TopologyClosedEvent(this.s.id));
498
-
499
- stateTransition(this, STATE_CLOSED);
500
-
501
- if (typeof callback === 'function') {
502
- callback(err);
503
- }
504
- }
505
- );
506
- });
510
+ eachAsync(
511
+ Array.from(this.s.sessions.values()),
512
+ (session, cb) => session.endSession(cb),
513
+ () => {
514
+ this.s.sessionPool.endAllPooledSessions(() => {
515
+ eachAsync(
516
+ Array.from(this.s.servers.values()),
517
+ (server, cb) => destroyServer(server, this, options, cb),
518
+ err => {
519
+ this.s.servers.clear();
520
+
521
+ // emit an event for close
522
+ this.emit(Topology.TOPOLOGY_CLOSED, new TopologyClosedEvent(this.s.id));
523
+
524
+ stateTransition(this, STATE_CLOSED);
525
+
526
+ if (typeof callback === 'function') {
527
+ callback(err);
528
+ }
529
+ }
530
+ );
531
+ });
532
+ }
533
+ );
507
534
  }
508
535
 
509
536
  /**
@@ -610,7 +637,7 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
610
637
  * @returns Whether sessions are supported on the current topology
611
638
  */
612
639
  hasSessionSupport(): boolean {
613
- return this.description.logicalSessionTimeoutMinutes != null;
640
+ return this.loadBalanced || this.description.logicalSessionTimeoutMinutes != null;
614
641
  }
615
642
 
616
643
  /** Start a logical session */
@@ -680,7 +707,7 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
680
707
  // value of the clusterTime embedded field."
681
708
  const clusterTime = serverDescription.$clusterTime;
682
709
  if (clusterTime) {
683
- resolveClusterTime(this, clusterTime);
710
+ _advanceClusterTime(this, clusterTime);
684
711
  }
685
712
 
686
713
  // If we already know all the information contained in this updated description, then
@@ -692,7 +719,7 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
692
719
  // first update the TopologyDescription
693
720
  this.s.description = this.s.description.update(serverDescription);
694
721
  if (this.s.description.compatibilityError) {
695
- this.emit(Topology.ERROR, new MongoDriverError(this.s.description.compatibilityError));
722
+ this.emit(Topology.ERROR, new MongoCompatibilityError(this.s.description.compatibilityError));
696
723
  return;
697
724
  }
698
725
 
@@ -749,8 +776,11 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
749
776
  return this.s.state === STATE_CLOSED;
750
777
  }
751
778
 
779
+ /**
780
+ * @deprecated This function is deprecated and will be removed in the next major version.
781
+ */
752
782
  unref(): void {
753
- emitWarning('not implemented: `unref`');
783
+ emitWarning('`unref` is a noop and will be removed in the next major version');
754
784
  }
755
785
 
756
786
  // NOTE: There are many places in code where we explicitly check the last isMaster
@@ -830,6 +860,10 @@ function topologyTypeFromOptions(options?: TopologyOptions) {
830
860
  return TopologyType.ReplicaSetNoPrimary;
831
861
  }
832
862
 
863
+ if (options?.loadBalanced) {
864
+ return TopologyType.LoadBalanced;
865
+ }
866
+
833
867
  return TopologyType.Unknown;
834
868
  }
835
869
 
@@ -954,10 +988,7 @@ function drainWaitQueue(queue: Denque<ServerSelectionRequest>, err?: MongoDriver
954
988
 
955
989
  function processWaitQueue(topology: Topology) {
956
990
  if (topology.s.state === STATE_CLOSED) {
957
- drainWaitQueue(
958
- topology[kWaitQueue],
959
- new MongoDriverError('Topology is closed, please connect')
960
- );
991
+ drainWaitQueue(topology[kWaitQueue], new MongoTopologyClosedError());
961
992
  return;
962
993
  }
963
994
 
@@ -3,7 +3,7 @@ import * as WIRE_CONSTANTS from '../cmap/wire_protocol/constants';
3
3
  import { TopologyType, ServerType } from './common';
4
4
  import type { ObjectId, Document } from '../bson';
5
5
  import type { SrvPollingEvent } from './srv_polling';
6
- import { MongoDriverError, MongoError } from '../error';
6
+ import { MongoError, MongoRuntimeError } from '../error';
7
7
 
8
8
  // constants related to compatibility checks
9
9
  const MIN_SUPPORTED_SERVER_VERSION = WIRE_CONSTANTS.MIN_SUPPORTED_SERVER_VERSION;
@@ -85,7 +85,13 @@ export class TopologyDescription {
85
85
 
86
86
  // determine server compatibility
87
87
  for (const serverDescription of this.servers.values()) {
88
- if (serverDescription.type === ServerType.Unknown) continue;
88
+ // Load balancer mode is always compatible.
89
+ if (
90
+ serverDescription.type === ServerType.Unknown ||
91
+ serverDescription.type === ServerType.LoadBalancer
92
+ ) {
93
+ continue;
94
+ }
89
95
 
90
96
  if (serverDescription.minWireVersion > MAX_SUPPORTED_WIRE_VERSION) {
91
97
  this.compatible = false;
@@ -113,7 +119,7 @@ export class TopologyDescription {
113
119
  break;
114
120
  }
115
121
 
116
- if (this.logicalSessionTimeoutMinutes === undefined) {
122
+ if (this.logicalSessionTimeoutMinutes == null) {
117
123
  // First server with a non null logicalSessionsTimeout
118
124
  this.logicalSessionTimeoutMinutes = server.logicalSessionTimeoutMinutes;
119
125
  continue;
@@ -431,7 +437,8 @@ function updateRsWithPrimaryFromMember(
431
437
  setName?: string
432
438
  ): TopologyType {
433
439
  if (setName == null) {
434
- throw new MongoDriverError('setName is required');
440
+ // TODO(NODE-3483): should be an appropriate runtime error
441
+ throw new MongoRuntimeError('Argument "setName" is required if connected to a replica set');
435
442
  }
436
443
 
437
444
  if (