MCPcopy
hub / github.com/mongodb/node-mongodb-native / maxWireVersion

Function maxWireVersion

src/utils.ts:332–370  ·  view source on GitHub ↗
(handshakeAware?: Connection | Topology | Server)

Source from the content-addressed store, hash-verified

330 * @internal
331 */
332export function maxWireVersion(handshakeAware?: Connection | Topology | Server): number {
333 if (handshakeAware) {
334 if (handshakeAware.hello) {
335 return handshakeAware.hello.maxWireVersion;
336 }
337
338 if (handshakeAware.serverApi?.version) {
339 // We return the max supported wire version for serverAPI.
340 return MAX_SUPPORTED_WIRE_VERSION;
341 }
342 // This is the fallback case for load balanced mode. If we are building commands the
343 // object being checked will be a connection, and we will have a hello response on
344 // it. For other cases, such as retryable writes, the object will be a server or
345 // topology, and there will be no hello response on those objects, so we return
346 // the max wire version so we support retryability. Once we have a min supported
347 // wire version of 9, then the needsRetryableWriteLabel() check can remove the
348 // usage of passing the wire version into it.
349 if (handshakeAware.loadBalanced) {
350 return MAX_SUPPORTED_WIRE_VERSION;
351 }
352
353 if ('lastHello' in handshakeAware && typeof handshakeAware.lastHello === 'function') {
354 const lastHello = handshakeAware.lastHello();
355 if (lastHello) {
356 return lastHello.maxWireVersion;
357 }
358 }
359
360 if (
361 handshakeAware.description &&
362 'maxWireVersion' in handshakeAware.description &&
363 handshakeAware.description.maxWireVersion != null
364 ) {
365 return handshakeAware.description.maxWireVersion;
366 }
367 }
368
369 return 0;
370}
371
372/** @internal */
373export function arrayStrictEqual(arr: unknown[], arr2: unknown[]): boolean {

Callers 15

supportsOpMsgMethod · 0.90
commandMethod · 0.90
authMethod · 0.90
_initializeMethod · 0.90
getMoreMethod · 0.90
commandMethod · 0.90
decorateCommandErrorMethod · 0.90
buildCommandDocumentMethod · 0.90
buildCommandDocumentMethod · 0.90
buildCommandDocumentMethod · 0.90
buildCommandMethod · 0.90
buildCommandDocumentMethod · 0.90

Calls 1

lastHelloMethod · 0.80

Tested by

no test coverage detected