From 9608fd5ab9c2b89a9880fd26202523ccdb539c66 Mon Sep 17 00:00:00 2001 From: Arsen Petrosyan Date: Wed, 4 Oct 2023 04:10:14 +0300 Subject: [PATCH] fix: Fixed typeorm mongodb health check fails with mongodb>=5.0 --- 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()); }); }