Skip to content

Commit

Permalink
shorten cokerPromise code
Browse files Browse the repository at this point in the history
  • Loading branch information
aditi-khare-mongoDB committed Mar 5, 2024
1 parent 25d1b44 commit a9ce7a8
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/cmap/handshake/client_metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,16 @@ export function makeClientMetadata(options: MakeClientMetadataOptions): ClientMe
}

let isDocker: boolean;
let dockerPromise: Promise<void>;
let dockerPromise: Promise<boolean>;
/** @internal */
async function getContainerMetadata() {
const containerMetadata: Record<string, any> = {};
if (isDocker == null) {
dockerPromise ??= fs.access('/.dockerenv');
try {
await dockerPromise;
isDocker = true;
} catch {
isDocker = false;
}
dockerPromise ??= fs.access('/.dockerenv').then(
() => true,
() => false
);
isDocker = await dockerPromise;
}

const { KUBERNETES_SERVICE_HOST = '' } = process.env;
Expand Down

0 comments on commit a9ce7a8

Please sign in to comment.