Skip to content

Commit c32ceda

Browse files
committed
fixes event emitting on client
Signed-off-by: Konstantina Blazhukova <konstantina.blajukova@gmail.com>
1 parent f6879cd commit c32ceda

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

packages/relay/src/lib/clients/cache/redisCache.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { Registry } from 'prom-client';
66
import { createClient } from 'redis';
77

88
import { Utils } from '../../../utils';
9-
import { RedisCacheError } from '../../errors/RedisCacheError';
109
import { IRedisCacheClient } from './IRedisCacheClient';
1110

1211
/**
@@ -51,15 +50,6 @@ export class RedisCache implements IRedisCacheClient {
5150
this.logger = logger;
5251
this.register = register;
5352
this.client = client;
54-
55-
this.client.on('error', (error) => {
56-
const redisError = new RedisCacheError(error);
57-
if (redisError.isSocketClosed()) {
58-
logger.error(`Error occurred with Redis Connection when closing socket: ${redisError.message}`);
59-
} else {
60-
logger.error(`Error occurred with Redis Connection: ${redisError.fullError}`);
61-
}
62-
});
6353
}
6454

6555
async getConnectedClient(): Promise<ReturnType<typeof createClient>> {

packages/relay/src/lib/relay.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { HbarSpendingPlanRepository } from './db/repositories/hbarLimiter/hbarSp
1717
import { IPAddressHbarSpendingPlanRepository } from './db/repositories/hbarLimiter/ipAddressHbarSpendingPlanRepository';
1818
import { DebugImpl } from './debug';
1919
import { RpcMethodDispatcher } from './dispatcher';
20+
import { RedisCacheError } from './errors/RedisCacheError';
2021
import { EthImpl } from './eth';
2122
import { NetImpl } from './net';
2223
import { CacheService } from './services/cacheService/cacheService';
@@ -364,10 +365,17 @@ export class Relay {
364365
redisClient.on('ready', () => {
365366
this.logger.info(`Redis client connected to ${redisUrl}`);
366367
});
368+
redisClient.on('end', () => {
369+
this.logger.info('Disconnected from Redis server!');
370+
});
367371
redisClient.on('error', (error) => {
368-
this.logger.error(error, 'Redis connection could not be established!');
372+
const redisError = new RedisCacheError(error);
373+
if (redisError.isSocketClosed()) {
374+
this.logger.error(`Error occurred with Redis Connection when closing socket: ${redisError.message}`);
375+
} else {
376+
this.logger.error(`Error occurred with Redis Connection: ${redisError.fullError}`);
377+
}
369378
});
370-
371379
return redisClient;
372380
}
373381
}

0 commit comments

Comments
 (0)