From dec471bb4b870ed24d229fb2e67b1b03051a06a3 Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Fri, 3 Nov 2023 17:12:46 -0300 Subject: [PATCH 1/2] fix issue with getNamesByFlagSets method in Redis and Pluggable split storage --- src/evaluator/index.ts | 7 +++++-- src/storages/inRedis/SplitsCacheInRedis.ts | 6 +++--- src/storages/pluggable/SplitsCachePluggable.ts | 6 +++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/evaluator/index.ts b/src/evaluator/index.ts index 70dad68a..62f82e98 100644 --- a/src/evaluator/index.ts +++ b/src/evaluator/index.ts @@ -94,7 +94,7 @@ export function evaluateFeaturesByFlagSets( flagSets: string[], attributes: SplitIO.Attributes | undefined, storage: IStorageSync | IStorageAsync, -): MaybeThenable> { +): MaybeThenable> { let storedFlagNames: MaybeThenable>; // get features by flag sets @@ -107,7 +107,10 @@ export function evaluateFeaturesByFlagSets( // evaluate related features return thenable(storedFlagNames) ? - storedFlagNames.then((splitNames) => evaluateFeatures(log, key, setToArray(splitNames), attributes, storage)) : + storedFlagNames.then((splitNames) => evaluateFeatures(log, key, setToArray(splitNames), attributes, storage)) + .catch(() => { + return {}; + }) : evaluateFeatures(log, key, setToArray(storedFlagNames), attributes, storage); } diff --git a/src/storages/inRedis/SplitsCacheInRedis.ts b/src/storages/inRedis/SplitsCacheInRedis.ts index 310c014d..754a370a 100644 --- a/src/storages/inRedis/SplitsCacheInRedis.ts +++ b/src/storages/inRedis/SplitsCacheInRedis.ts @@ -5,7 +5,7 @@ import { ILogger } from '../../logger/types'; import { LOG_PREFIX } from './constants'; import { ISplit } from '../../dtos/types'; import { AbstractSplitsCacheAsync } from '../AbstractSplitsCacheAsync'; -import { ISet, _Set } from '../../utils/lang/sets'; +import { ISet } from '../../utils/lang/sets'; /** * Discard errors for an answer of multiple operations. @@ -196,8 +196,8 @@ export class SplitsCacheInRedis extends AbstractSplitsCacheAsync { * @todo this is a no-op method to be implemented */ getNamesByFlagSets(): Promise> { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - return new Promise(flagSets => new _Set([])); + this.log.warn(LOG_PREFIX + 'ByFlagSet/s evaluations are not supported in Redis storage yet.'); + return Promise.reject(); } /** diff --git a/src/storages/pluggable/SplitsCachePluggable.ts b/src/storages/pluggable/SplitsCachePluggable.ts index c6dce829..45ed0282 100644 --- a/src/storages/pluggable/SplitsCachePluggable.ts +++ b/src/storages/pluggable/SplitsCachePluggable.ts @@ -5,7 +5,7 @@ import { ILogger } from '../../logger/types'; import { ISplit } from '../../dtos/types'; import { LOG_PREFIX } from './constants'; import { AbstractSplitsCacheAsync } from '../AbstractSplitsCacheAsync'; -import { ISet, _Set } from '../../utils/lang/sets'; +import { ISet } from '../../utils/lang/sets'; /** * ISplitsCacheAsync implementation for pluggable storages. @@ -162,8 +162,8 @@ export class SplitsCachePluggable extends AbstractSplitsCacheAsync { * @todo this is a no-op method to be implemented */ getNamesByFlagSets(): Promise> { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - return new Promise(flagSets => new _Set([])); + this.log.warn(LOG_PREFIX + 'ByFlagSet/s evaluations are not supported in pluggable storage yet.'); + return Promise.reject(); } /** From 827b91e1d3947e9aa1ffe361c6db1b47191a46d2 Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Fri, 3 Nov 2023 17:59:33 -0300 Subject: [PATCH 2/2] update log level and message --- src/storages/inRedis/SplitsCacheInRedis.ts | 2 +- src/storages/pluggable/SplitsCachePluggable.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/storages/inRedis/SplitsCacheInRedis.ts b/src/storages/inRedis/SplitsCacheInRedis.ts index 754a370a..f58f49ab 100644 --- a/src/storages/inRedis/SplitsCacheInRedis.ts +++ b/src/storages/inRedis/SplitsCacheInRedis.ts @@ -196,7 +196,7 @@ export class SplitsCacheInRedis extends AbstractSplitsCacheAsync { * @todo this is a no-op method to be implemented */ getNamesByFlagSets(): Promise> { - this.log.warn(LOG_PREFIX + 'ByFlagSet/s evaluations are not supported in Redis storage yet.'); + this.log.error(LOG_PREFIX + 'ByFlagSet/s evaluations are not supported with Redis storage yet.'); return Promise.reject(); } diff --git a/src/storages/pluggable/SplitsCachePluggable.ts b/src/storages/pluggable/SplitsCachePluggable.ts index 45ed0282..786fb8a5 100644 --- a/src/storages/pluggable/SplitsCachePluggable.ts +++ b/src/storages/pluggable/SplitsCachePluggable.ts @@ -162,7 +162,7 @@ export class SplitsCachePluggable extends AbstractSplitsCacheAsync { * @todo this is a no-op method to be implemented */ getNamesByFlagSets(): Promise> { - this.log.warn(LOG_PREFIX + 'ByFlagSet/s evaluations are not supported in pluggable storage yet.'); + this.log.error(LOG_PREFIX + 'ByFlagSet/s evaluations are not supported with pluggable storage yet.'); return Promise.reject(); }