Skip to content

Commit 58040dc

Browse files
Merge branch 'development' into impressions_toggle_baseline
2 parents d83c0ad + 1b9874e commit 58040dc

File tree

9 files changed

+16
-27
lines changed

9 files changed

+16
-27
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
2.1.0 (January XX, 2025)
22
- Added `trackImpressions` property to SDK Manager's `SplitView` type.
33
- Updated implementation of the impressions tracker and strategies to support feature flags with impressions tracking disabled.
4+
- Bugfixing - Properly handle rejected promises when using targeting rules with segment matchers in consumer modes (e.g., Redis and Pluggable storages).
45

56
2.0.2 (December 3, 2024)
67
- 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.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This library is compatible with JavaScript ES5 and above.
1414
Please see [Contributors Guide](CONTRIBUTORS-GUIDE.md) to find all you need to submit a Pull Request (PR).
1515

1616
## License
17-
Licensed under the Apache License, Version 2.0. See: [Apache License](http://www.apache.org/licenses/).
17+
Licensed under the Apache License, Version 2.0. See: [Apache License](https://www.apache.org/licenses/).
1818

1919
## About Split
2020

@@ -46,4 +46,4 @@ For a comprehensive list of open source projects visit our [Github page](https:/
4646

4747
**Learn more about Split:**
4848

49-
Visit [split.io/product](https://www.split.io/product) for an overview of Split, or visit our documentation at [help.split.io](http://help.split.io) for more detailed information.
49+
Visit [split.io/product](https://www.split.io/product) for an overview of Split, or visit our documentation at [help.split.io](https://help.split.io) for more detailed information.
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);

src/sync/streaming/pushManager.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,14 @@ export function pushManagerFactory(
349349
// Reconnects in case of a new client.
350350
// Run in next event-loop cycle to save authentication calls
351351
// in case multiple clients are created in the current cycle.
352-
setTimeout(function checkForReconnect() {
353-
if (connectForNewClient) {
354-
connectForNewClient = false;
355-
connectPush();
356-
}
357-
}, 0);
352+
if (this.isRunning()) {
353+
setTimeout(function checkForReconnect() {
354+
if (connectForNewClient) {
355+
connectForNewClient = false;
356+
connectPush();
357+
}
358+
}, 0);
359+
}
358360
}
359361
},
360362
// [Only for client-side]

src/sync/syncManagerOnline.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,19 +142,19 @@ export function syncManagerOnlineFactory(
142142
if (!pollingManager) return;
143143

144144
const mySegmentsSyncTask = (pollingManager as IPollingManagerCS).add(matchingKey, readinessManager, storage);
145+
if (syncEnabled && pushManager) pushManager.add(matchingKey, mySegmentsSyncTask);
145146

146147
if (running) {
147148
if (syncEnabled) {
148149
if (pushManager) {
149-
if (pollingManager!.isRunning()) {
150+
if (pollingManager.isRunning()) {
150151
// if doing polling, we must start the periodic fetch of data
151152
if (storage.splits.usesSegments()) mySegmentsSyncTask.start();
152153
} else {
153154
// if not polling, we must execute the sync task for the initial fetch
154155
// of segments since `syncAll` was already executed when starting the main client
155156
mySegmentsSyncTask.execute();
156157
}
157-
pushManager.add(matchingKey, mySegmentsSyncTask);
158158
} else {
159159
if (storage.splits.usesSegments()) mySegmentsSyncTask.start();
160160
}

types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Declaration file for JavaScript Browser Split Software SDK
2-
// Project: http://www.split.io/
2+
// Project: https://www.split.io/
33
// Definitions by: Nico Zelaya <https://github.com/NicoZelaya/>
44

55
/// <reference path="./splitio.d.ts" />

types/splitio.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Type definitions for Split Software SDKs
2-
// Project: http://www.split.io/
2+
// Project: https://www.split.io/
33

44
import { RedisOptions } from 'ioredis';
55
import { RequestOptions } from 'http';

0 commit comments

Comments
 (0)