@@ -3,7 +3,7 @@ import Redis, { RedisOptions } from 'ioredis';
3
3
// TODO: remove get from OPTIONS
4
4
const BULL_REDIS_URI = process . env . BULL_REDIS_URI || 'redis://127.0.0.1:6379' ;
5
5
6
- const redisInstances = new Map < string , Redis . Redis > ( ) ;
6
+ const redisInstances = new Map < string , Redis > ( ) ;
7
7
8
8
export function createBullConnection ( type : 'queue' | 'worker' | 'scheduler' | 'events' | 'custom' ) {
9
9
const existedClient = redisInstances . get ( type ) ;
@@ -33,9 +33,10 @@ export function createBullConnection(type: 'queue' | 'worker' | 'scheduler' | 'e
33
33
* rediss://localhost/0
34
34
* redis-sentinel://:pass@localhost:26379,otherhost:26479/0?name=mymaster
35
35
*/
36
- export function connectRedis ( uri : string , opts ?: RedisOptions ) : Redis . Redis {
36
+ export function connectRedis ( uri : string , opts ?: RedisOptions ) : Redis {
37
37
// TODO: UnhandledPromiseRejectionWarning: MaxRetriesPerRequestError: Reached the max retries per request limit (which is 20). Refer to "maxRetriesPerRequest" option for details.
38
38
let cfg = {
39
+ maxRetriesPerRequest : null ,
39
40
retryStrategy : ( times : number ) => Math . min ( times * 500 , 10000 ) ,
40
41
reconnectOnError : ( err : Error ) => {
41
42
const targetError = 'READONLY' ;
@@ -170,12 +171,12 @@ export function connectionStringSerialize(connectionStringObject: ConnectionStri
170
171
export function connectionStringParse ( uri : string ) : ConnectionStringParameters {
171
172
const connectionStringParser = new RegExp (
172
173
'^\\s*' + // Optional whitespace padding at the beginning of the line
173
- '([^:]+):\\/\\/' + // Scheme (Group 1)
174
- '(?:([^:@,/?=&]*)' + // User (Group 2)
175
- '(?::([^:@,/?=&]*))?@)?' + // Password (Group 3)
176
- '([^@/?=&]+)' + // Host address(es) (Group 4)
177
- '(?:\\/([^:@,?=&]+)?)?' + // Endpoint (Group 5)
178
- '(?:\\?([^:@,/?]+)?)?' + // Options (Group 6)
174
+ '([^:]+):\\/\\/' + // Scheme (Group 1)
175
+ '(?:([^:@,/?=&]*)' + // User (Group 2)
176
+ '(?::([^:@,/?=&]*))?@)?' + // Password (Group 3)
177
+ '([^@/?=&]+)' + // Host address(es) (Group 4)
178
+ '(?:\\/([^:@,?=&]+)?)?' + // Endpoint (Group 5)
179
+ '(?:\\?([^:@,/?]+)?)?' + // Options (Group 6)
179
180
'\\s*$' , // Optional whitespace padding at the end of the line
180
181
'gi'
181
182
) ;
@@ -222,9 +223,11 @@ function _parseAddress(addresses: string): ConnectionStringHost[] {
222
223
return addresses . split ( ',' ) . map ( ( address ) => {
223
224
const i = address . indexOf ( ':' ) ;
224
225
225
- return ( i >= 0
226
- ? { host : decodeURIComponent ( address . substring ( 0 , i ) ) , port : + address . substring ( i + 1 ) }
227
- : { host : decodeURIComponent ( address ) } ) as ConnectionStringHost ;
226
+ return (
227
+ i >= 0
228
+ ? { host : decodeURIComponent ( address . substring ( 0 , i ) ) , port : + address . substring ( i + 1 ) }
229
+ : { host : decodeURIComponent ( address ) }
230
+ ) as ConnectionStringHost ;
228
231
} ) ;
229
232
}
230
233
0 commit comments