Skip to content

Commit ab42194

Browse files
committed
Request build info in parallel with getting connect extra info
1 parent 4c31948 commit ab42194

File tree

1 file changed

+38
-26
lines changed

1 file changed

+38
-26
lines changed

packages/service-provider-node-driver/src/node-driver-service-provider.ts

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -472,40 +472,52 @@ export class NodeDriverServiceProvider
472472
}
473473

474474
async getConnectionInfo(): Promise<ConnectionInfo> {
475-
const [buildInfo = null, atlasVersion = null, fcv = null, atlascliInfo] =
475+
const buildInfoPromise = this.runCommandWithCheck(
476+
'admin',
477+
{ buildInfo: 1 },
478+
this.baseCmdOptions
479+
).catch(() => {});
480+
481+
const isLocalAtlasPromise = this.countDocuments('admin', 'atlascli', {
482+
managedClusterType: 'atlasCliLocalDevCluster',
483+
}).then(
484+
(result) => !!result,
485+
() => false
486+
);
487+
488+
const atlasVersionPromise = this.runCommandWithCheck(
489+
'admin',
490+
{ atlasVersion: 1 },
491+
this.baseCmdOptions
492+
).then(
493+
(response) =>
494+
typeof response.atlasVersion === 'string'
495+
? response.atlasVersion
496+
: undefined,
497+
() => undefined
498+
);
499+
500+
const resolvedHostname = this._getHostnameForConnection(
501+
this._lastSeenTopology
502+
);
503+
504+
const [buildInfo = null, fcv = null, extraConnectionInfo] =
476505
await Promise.all([
477-
this.runCommandWithCheck(
478-
'admin',
479-
{ buildInfo: 1 },
480-
this.baseCmdOptions
481-
).catch(() => {}),
482-
this.runCommandWithCheck(
483-
'admin',
484-
{ atlasVersion: 1 },
485-
this.baseCmdOptions
486-
).catch(() => {}),
506+
buildInfoPromise,
487507
this.runCommandWithCheck(
488508
'admin',
489509
{ getParameter: 1, featureCompatibilityVersion: 1 },
490510
this.baseCmdOptions
491511
).catch(() => {}),
492-
this.countDocuments('admin', 'atlascli', {
493-
managedClusterType: 'atlasCliLocalDevCluster',
494-
}).catch(() => 0),
512+
getConnectExtraInfo({
513+
connectionString: this.uri,
514+
buildInfo: buildInfoPromise,
515+
atlasVersion: atlasVersionPromise,
516+
resolvedHostname,
517+
isLocalAtlas: isLocalAtlasPromise,
518+
}),
495519
]);
496520

497-
const resolvedHostname = this._getHostnameForConnection(
498-
this._lastSeenTopology
499-
);
500-
501-
const extraConnectionInfo = getConnectExtraInfo({
502-
connectionString: this.uri,
503-
buildInfo,
504-
atlasVersion,
505-
resolvedHostname,
506-
isLocalAtlas: !!atlascliInfo,
507-
});
508-
509521
return {
510522
buildInfo,
511523
resolvedHostname,

0 commit comments

Comments
 (0)