From b6026c2e863c0a509177749cd6ee82a0a5bc2030 Mon Sep 17 00:00:00 2001 From: Arsen Petrosyan Date: Sun, 26 Nov 2023 20:26:37 +0200 Subject: [PATCH] fix: Fixed typeorm mongodb health check fails with mongodb>=5.0 (#2399) --- lib/health-indicator/database/typeorm.health.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/health-indicator/database/typeorm.health.ts b/lib/health-indicator/database/typeorm.health.ts index d5f1c7ace..d6b0372b4 100644 --- a/lib/health-indicator/database/typeorm.health.ts +++ b/lib/health-indicator/database/typeorm.health.ts @@ -79,13 +79,10 @@ export class TypeOrmHealthIndicator extends HealthIndicator { ? connection.options.url : driver.buildConnectionUrl(connection.options), driver.buildConnectionOptions(connection.options), - (err: Error, client: any) => { - if (err) { - return reject(new MongoConnectionError(err.message)); - } - client.close(() => resolve()); - }, - ); + ) + .catch((err: Error) => reject(new MongoConnectionError(err.message))) + .then((client: TypeOrm.MongoClient) => client.close().catch(() => {})) + .then(() => resolve()); }); }