Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/mongodb-build-info/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ export function getGenuineMongoDB(uri: string): {
type IdentifyServerNameOptions = {
connectionString: string;
adminCommand: (command: Document) => Promise<Document>;
/** Pass this to prevent multiple requests for the same data */
buildInfo?: Promise<Document>;
};

/**
Expand All @@ -155,6 +157,7 @@ type IdentifyServerNameOptions = {
export async function identifyServerName({
connectionString,
adminCommand,
buildInfo,
}: IdentifyServerNameOptions): Promise<string> {
try {
const hostname = getHostnameFromUrl(connectionString);
Expand All @@ -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'];
Expand Down
Loading