Skip to content
Snippets Groups Projects
Commit 97d39b33 authored by FORESTIER Fabien's avatar FORESTIER Fabien
Browse files

Quit the redis client in health check and timeout the client connection if longer than 2 seconds

parent daa4a1a4
No related branches found
No related tags found
1 merge request!2Version 3.2.1
Pipeline #3152 passed
...@@ -16,6 +16,7 @@ export class RedisHealthIndicator extends HealthIndicator { ...@@ -16,6 +16,7 @@ export class RedisHealthIndicator extends HealthIndicator {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
client.on('ready', resolve); client.on('ready', resolve);
client.on('error', reject); client.on('error', reject);
setTimeout(reject, 2000);
}).catch((err) => { }).catch((err) => {
client.quit(); client.quit();
throw new HealthCheckError('Redis connection failed', { throw new HealthCheckError('Redis connection failed', {
...@@ -27,6 +28,8 @@ export class RedisHealthIndicator extends HealthIndicator { ...@@ -27,6 +28,8 @@ export class RedisHealthIndicator extends HealthIndicator {
}); });
}); });
client.quit();
return this.getStatus('Redis', true); return this.getStatus('Redis', true);
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment