Skip to content

Commit 1b9874e

Browse files
Merge pull request #381 from splitio/consumer_mode_polishing
Bugfix: handle rejected promises when using segment matchers
2 parents eafea0f + 4ebcff9 commit 1b9874e

File tree

4 files changed

+4
-15
lines changed

4 files changed

+4
-15
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2.0.3 (December 29, 2024)
2+
- Bugfixing - Properly handle rejected promises when using targeting rules with segment matchers in consumer modes (e.g., Redis and Pluggable storages).
3+
14
2.0.2 (December 3, 2024)
25
- Updated the factory `init` and `destroy` methods to support re-initialization after destruction. This update ensures compatibility of the React SDK with React Strict Mode, where the factory's `init` and `destroy` effects are executed an extra time to validate proper resource cleanup.
36
- Bugfixing - Sanitize the `SplitSDKMachineName` header value to avoid exceptions on HTTP/S requests when it contains non ISO-8859-1 characters (Related to issue https://github.com/splitio/javascript-client/issues/847).
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
import { MaybeThenable } from '../../dtos/types';
22
import { ISegmentsCacheBase } from '../../storages/types';
3-
import { thenable } from '../../utils/promise/thenable';
43

54
export function largeSegmentMatcherContext(largeSegmentName: string, storage: { largeSegments?: ISegmentsCacheBase }) {
65

76
return function largeSegmentMatcher(key: string): MaybeThenable<boolean> {
87
const isInLargeSegment = storage.largeSegments ? storage.largeSegments.isInSegment(largeSegmentName, key) : false;
98

10-
if (thenable(isInLargeSegment)) {
11-
isInLargeSegment.then(result => {
12-
return result;
13-
});
14-
}
15-
169
return isInLargeSegment;
1710
};
1811
}

src/evaluator/matchers/segment.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
import { MaybeThenable } from '../../dtos/types';
22
import { ISegmentsCacheBase } from '../../storages/types';
3-
import { thenable } from '../../utils/promise/thenable';
43

54
export function segmentMatcherContext(segmentName: string, storage: { segments: ISegmentsCacheBase }) {
65

76
return function segmentMatcher(key: string): MaybeThenable<boolean> {
87
const isInSegment = storage.segments.isInSegment(segmentName, key);
98

10-
if (thenable(isInSegment)) {
11-
isInSegment.then(result => {
12-
return result;
13-
});
14-
}
15-
169
return isInSegment;
1710
};
1811
}

src/storages/inRedis/SplitsCacheInRedis.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,10 @@ export class SplitsCacheInRedis extends AbstractSplitsCacheAsync {
266266
return Promise.reject(this.redisError);
267267
}
268268

269-
const splits: Record<string, ISplit | null> = {};
270269
const keys = names.map(name => this.keys.buildSplitKey(name));
271270
return this.redis.mget(...keys)
272271
.then(splitDefinitions => {
272+
const splits: Record<string, ISplit | null> = {};
273273
names.forEach((name, idx) => {
274274
const split = splitDefinitions[idx];
275275
splits[name] = split && JSON.parse(split);

0 commit comments

Comments
 (0)