@@ -10,11 +10,11 @@ import type { RedisAdapter } from './RedisAdapter';
1010/**
1111 * Discard errors for an answer of multiple operations.
1212 */
13- function processPipelineAnswer ( results : Array < [ Error | null , string ] > ) : string [ ] {
14- return results . reduce ( ( accum : string [ ] , errValuePair : [ Error | null , string ] ) => {
15- if ( errValuePair [ 0 ] === null ) accum . push ( errValuePair [ 1 ] ) ;
13+ function processPipelineAnswer ( results : Array < [ Error | null , unknown ] > | null ) : string [ ] {
14+ return results ? results . reduce ( ( accum : string [ ] , errValuePair : [ Error | null , unknown ] ) => {
15+ if ( errValuePair [ 0 ] === null ) accum . push ( errValuePair [ 1 ] as string ) ;
1616 return accum ;
17- } , [ ] ) ;
17+ } , [ ] ) : [ ] ;
1818}
1919
2020/**
@@ -26,7 +26,7 @@ export class SplitsCacheInRedis extends AbstractSplitsCacheAsync {
2626 private readonly log : ILogger ;
2727 private readonly redis : RedisAdapter ;
2828 private readonly keys : KeyBuilderSS ;
29- private redisError ?: string ;
29+ private redisError ?: Error ;
3030 private readonly flagSetsFilter : string [ ] ;
3131
3232 constructor ( log : ILogger , keys : KeyBuilderSS , redis : RedisAdapter , splitFiltersValidation ?: ISplitFiltersValidation ) {
@@ -198,11 +198,11 @@ export class SplitsCacheInRedis extends AbstractSplitsCacheAsync {
198198 */
199199 getNamesByFlagSets ( flagSets : string [ ] ) : Promise < Set < string > [ ] > {
200200 return this . redis . pipeline ( flagSets . map ( flagSet => [ 'smembers' , this . keys . buildFlagSetKey ( flagSet ) ] ) ) . exec ( )
201- . then ( ( results ) => results . map ( ( [ e , value ] , index ) => {
202- if ( e === null ) return value ;
201+ . then ( ( results ) => results ? results . map ( ( [ e , value ] , index ) => {
202+ if ( e === null ) return value as string ;
203203
204204 this . log . error ( LOG_PREFIX + `Could not read result from get members of flag set ${ flagSets [ index ] } due to an error: ${ e } ` ) ;
205- } ) )
205+ } ) : [ ] )
206206 . then ( namesByFlagSets => namesByFlagSets . map ( namesByFlagSet => new Set ( namesByFlagSet ) ) ) ;
207207 }
208208
0 commit comments