@@ -30,21 +30,22 @@ async function connect(body) {
30
30
host : body . serverModel . ip , port : body . serverModel . port , db : body . serverModel . db ,
31
31
password : body . serverModel . password ,
32
32
showFriendlyErrorStack : true ,
33
- maxRetriesPerRequest : 10 ,
34
33
} ) ;
35
-
36
- body . serverModel . id = body . id ;
37
34
38
35
const timeoutHandler = setTimeout ( ( ) => {
39
36
redis . disconnect ( ) ;
40
- reject ( errors . newConnectTimeoutError ( body . serverModel ) ) ;
37
+ reject ( errors . newConnectTimeoutError ( body . id ) ) ;
41
38
} , 3 * 1000 ) ;
42
39
43
40
redis . on ( 'error' , ( e ) => {
44
41
console . error ( e ) ;
45
42
body . status = DISCONNECTED ;
46
43
} ) ;
47
44
45
+ redis . on ( 'end' , ( ) => {
46
+ redisInstanceCache [ body . id ] = null ;
47
+ } ) ;
48
+
48
49
redis . on ( 'ready' , ( ) => {
49
50
body . redis = redis ;
50
51
body . status = CONNECTED ;
@@ -63,8 +64,8 @@ async function connect(body) {
63
64
*/
64
65
function getRedisConnection ( query ) {
65
66
const redisConn = redisInstanceCache [ query . id ] ;
66
- if ( ! redisConn && redisConn . status !== CONNECTED ) {
67
- throw errors . newConnectFailedError ( redisConn ? redisConn . serverModel : { } ) ;
67
+ if ( ! redisConn || redisConn . status !== CONNECTED ) {
68
+ throw errors . newConnectFailedError ( query . id ) ;
68
69
}
69
70
return redisConn ;
70
71
}
@@ -100,7 +101,7 @@ async function fetchTree(query) {
100
101
}
101
102
}
102
103
} catch ( e ) {
103
- throw errors . newReplyError ( redisConn . serverModel , e . message ) ;
104
+ throw errors . newReplyError ( query . id , e . message ) ;
104
105
}
105
106
106
107
const tree = { } ;
@@ -183,7 +184,7 @@ async function call(query, body) {
183
184
try {
184
185
results . push ( await redis . call ( ...lines [ i ] ) ) ;
185
186
} catch ( e ) {
186
- throw errors . newReplyError ( redisConn . serverModel , e . message , i + 1 ) ;
187
+ throw errors . newReplyError ( query . id , e . message , i + 1 ) ;
187
188
}
188
189
}
189
190
return results ;
@@ -201,7 +202,7 @@ async function dump(query) {
201
202
try {
202
203
return await redisDump ( query . exportType , redis ) ;
203
204
} catch ( e ) {
204
- throw errors . newReplyError ( redisConn . serverModel , e . message ) ;
205
+ throw errors . newReplyError ( query . id , e . message ) ;
205
206
}
206
207
}
207
208
0 commit comments