Skip to content

Commit 36ae03e

Browse files
Merge pull request #367 from splitio/handle_empty_segments_till
Bugfix SDK_UPDATE on server side
2 parents d6d14f9 + ac4fe58 commit 36ae03e

File tree

16 files changed

+39
-39
lines changed

16 files changed

+39
-39
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.1 (November 25, 2024)
2+
- Bugfixing - Fixed an issue with the SDK_UPDATE event on server-side, where it was not being emitted if there was an empty segment and the SDK received a feature flag update notification.
3+
14
2.0.0 (November 1, 2024)
25
- Added support for targeting rules based on large segments.
36
- Added `factory.destroy()` method, which invokes the `destroy` method on all SDK clients created by the factory.

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@splitsoftware/splitio-commons",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "Split JavaScript SDK common components",
55
"main": "cjs/index.js",
66
"module": "esm/index.js",

src/sdkClient/sdkClient.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,18 @@ export function sdkClientFactory(params: ISdkFactoryContext, isSharedClient?: bo
5656
// Mark the SDK as destroyed immediately
5757
sdkReadinessManager.readinessManager.destroy();
5858

59-
// For main client, release the SDK Key and record stat before flushing data
59+
// For main client, cleanup the SDK Key, listeners and scheduled jobs, and record stat before flushing data
6060
if (!isSharedClient) {
6161
releaseApiKey(settings.core.authorizationKey);
6262
telemetryTracker.sessionLength();
63+
signalListener && signalListener.stop();
64+
uniqueKeysTracker && uniqueKeysTracker.stop();
6365
}
6466

6567
// Stop background jobs
6668
syncManager && syncManager.stop();
6769

6870
return __flush().then(() => {
69-
// For main client, cleanup event listeners and scheduled jobs
70-
if (!isSharedClient) {
71-
signalListener && signalListener.stop();
72-
uniqueKeysTracker && uniqueKeysTracker.stop();
73-
}
74-
7571
// Cleanup storage
7672
return storage.destroy();
7773
});

src/storages/AbstractMySegmentsCacheSync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export abstract class AbstractMySegmentsCacheSync implements ISegmentsCacheSync
4242
// @TODO for client-side it should be the number of clients, but it requires a refactor of MySegments caches to simplify the code.
4343
abstract getKeysCount(): number
4444

45-
abstract getChangeNumber(name: string): number
45+
abstract getChangeNumber(): number
4646

4747
/**
4848
* For server-side synchronizer: the method is not used.

src/storages/inMemory/SegmentsCacheInMemory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export class SegmentsCacheInMemory implements ISegmentsCacheSync {
6565
getChangeNumber(name: string) {
6666
const value = this.segmentChangeNumber[name];
6767

68-
return isIntegerNumber(value) ? value : -1;
68+
return isIntegerNumber(value) ? value : undefined;
6969
}
7070

7171
// No-op. Not used in server-side

src/storages/inRedis/SegmentsCacheInRedis.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ export class SegmentsCacheInRedis implements ISegmentsCacheAsync {
4444
return this.redis.get(this.keys.buildSegmentTillKey(name)).then((value: string | null) => {
4545
const i = parseInt(value as string, 10);
4646

47-
return isNaNNumber(i) ? -1 : i;
47+
return isNaNNumber(i) ? undefined : i;
4848
}).catch((e) => {
4949
this.log.error(LOG_PREFIX + 'Could not retrieve changeNumber from segments storage. Error: ' + e);
50-
return -1;
50+
return undefined;
5151
});
5252
}
5353

src/storages/inRedis/__tests__/SegmentsCacheInRedis.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('SEGMENTS CACHE IN REDIS', () => {
1717

1818
expect(await cache.getChangeNumber('mocked-segment') === 1).toBe(true);
1919

20-
expect(await cache.getChangeNumber('inexistent-segment')).toBe(-1); // -1 if the segment doesn't exist
20+
expect(await cache.getChangeNumber('inexistent-segment')).toBe(undefined); // -1 if the segment doesn't exist
2121

2222
await cache.update('mocked-segment', ['d', 'e'], [], 2);
2323

src/storages/pluggable/SegmentsCachePluggable.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ export class SegmentsCachePluggable implements ISegmentsCacheAsync {
5555
return this.wrapper.get(this.keys.buildSegmentTillKey(name)).then((value: string | null) => {
5656
const i = parseInt(value as string, 10);
5757

58-
return isNaNNumber(i) ? -1 : i;
58+
return isNaNNumber(i) ? undefined : i;
5959
}).catch((e) => {
6060
this.log.error(LOG_PREFIX + 'Could not retrieve changeNumber from segments storage. Error: ' + e);
61-
return -1;
61+
return undefined;
6262
});
6363
}
6464

src/storages/pluggable/__tests__/SegmentsCachePluggable.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('SEGMENTS CACHE PLUGGABLE', () => {
2020

2121
expect(await cache.getChangeNumber('mocked-segment') === 1).toBe(true);
2222

23-
expect(await cache.getChangeNumber('inexistent-segment')).toBe(-1); // -1 if the segment doesn't exist
23+
expect(await cache.getChangeNumber('inexistent-segment')).toBe(undefined); // -1 if the segment doesn't exist
2424

2525
await cache.update('mocked-segment', ['d', 'e'], [], 2);
2626

0 commit comments

Comments
 (0)