From 3da4d1ccb648b3415386138c83af0e3b911b98a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Fri, 31 Oct 2025 14:30:14 +0100 Subject: [PATCH] Allow passing a promise of build info --- packages/mongodb-build-info/src/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/mongodb-build-info/src/index.ts b/packages/mongodb-build-info/src/index.ts index 07111a9f..e72f4e39 100644 --- a/packages/mongodb-build-info/src/index.ts +++ b/packages/mongodb-build-info/src/index.ts @@ -146,6 +146,8 @@ export function getGenuineMongoDB(uri: string): { type IdentifyServerNameOptions = { connectionString: string; adminCommand: (command: Document) => Promise; + /** Pass this to prevent multiple requests for the same data */ + buildInfo?: Promise; }; /** @@ -155,6 +157,7 @@ type IdentifyServerNameOptions = { export async function identifyServerName({ connectionString, adminCommand, + buildInfo, }: IdentifyServerNameOptions): Promise { try { const hostname = getHostnameFromUrl(connectionString); @@ -175,7 +178,7 @@ export async function identifyServerName({ } const candidates = await Promise.all([ - adminCommand({ buildInfo: 1 }).then( + (buildInfo ?? adminCommand({ buildInfo: 1 })).then( (response) => { if ('ferretdb' in response) { return ['ferretdb'];