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()); }); }