@@ -52,27 +52,26 @@ class RedisClient {
5252 async createClientAndConnect ( options , errorHandlerCreateClient , isConnectionCheck ) {
5353 try {
5454 const client = this . createClientBase ( options ) ;
55- if ( ! client ) {
56- return ;
57- }
58- if ( ! isConnectionCheck ) {
59- client . on ( "error" , ( err ) => {
60- const dateNow = Date . now ( ) ;
61- if ( dateNow - this . lastErrorLog > LOG_AFTER_SEC * 1000 ) {
62- this . log . error ( "Error from redis client" , err ) ;
63- this . lastErrorLog = dateNow ;
64- }
65- } ) ;
55+ if ( client ) {
56+ if ( ! isConnectionCheck ) {
57+ client . on ( "error" , ( err ) => {
58+ const dateNow = Date . now ( ) ;
59+ if ( dateNow - this . lastErrorLog > LOG_AFTER_SEC * 1000 ) {
60+ this . log . error ( "Error from redis client" , err ) ;
61+ this . lastErrorLog = dateNow ;
62+ }
63+ } ) ;
6664
67- client . on ( "reconnecting" , ( ) => {
68- const dateNow = Date . now ( ) ;
69- if ( dateNow - this . lastErrorLog > LOG_AFTER_SEC * 1000 ) {
70- this . log . info ( "Redis client trying reconnect..." ) ;
71- this . lastErrorLog = dateNow ;
72- }
73- } ) ;
65+ client . on ( "reconnecting" , ( ) => {
66+ const dateNow = Date . now ( ) ;
67+ if ( dateNow - this . lastErrorLog > LOG_AFTER_SEC * 1000 ) {
68+ this . log . info ( "Redis client trying reconnect..." ) ;
69+ this . lastErrorLog = dateNow ;
70+ }
71+ } ) ;
72+ }
73+ await client . connect ( ) ;
7474 }
75- await client . connect ( ) ;
7675 return client ;
7776 } catch ( err ) {
7877 errorHandlerCreateClient ( err ) ;
@@ -277,8 +276,7 @@ class RedisClient {
277276 try {
278277 if ( client ?. close ) {
279278 await client . close ( ) ;
280- }
281- if ( client ?. quit ) {
279+ } else if ( client ?. quit ) {
282280 await client . quit ( ) ;
283281 }
284282 } catch ( err ) {
0 commit comments