Skip to content

Commit cd09ac7

Browse files
Merge pull request #368 from splitio/development
Release v2.0.1
2 parents f384cb8 + 36ae03e commit cd09ac7

File tree

26 files changed

+74
-74
lines changed

26 files changed

+74
-74
lines changed

CHANGES.txt

Lines changed: 6 additions & 3 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.
@@ -20,7 +23,7 @@
2023
- Updated some transitive dependencies for vulnerability fixes.
2124

2225
1.16.0 (June 13, 2024)
23-
- Added the `getOptions` method to the `IPlatform` interface to allow the SDK to pass request options to the `fetch` function and `EventSource` constructor when fetching data from the Split servers. The method is optional and, if provided, it is called twice: first for the `fetch` options and then for the `EventSource` options. Useful for advanced use cases like configuring a proxy or validating HTTPS certificates in NodeJS.
26+
- Added the `getOptions` method to the `IPlatform` interface to allow the SDK to pass request options to the `fetch` function and `EventSource` constructor when fetching data from the Split servers. The method is optional and, if provided, it is called twice: first for the `fetch` options and then for the `EventSource` options. Useful for advanced use cases like configuring a proxy or validating HTTPS certificates in Node.js.
2427
- Updated the Redis storage to lazily import the `ioredis` dependency when the storage is created. This prevents errors when the SDK is imported or bundled in a .mjs file, as `ioredis` is a CommonJS module.
2528
- Bugfixing - Restored some input validation error logs that were removed in version 1.12.0. The logs inform the user when the `getTreatment(s)` methods are called with an invalid value as feature flag name or flag set name.
2629
- Bugfixing - Fixed localhost mode to emit SDK_UPDATE when mocked feature flags are updated in the `features` object map of the config object (Related to issue https://github.com/splitio/javascript-browser-client/issues/119).
@@ -57,7 +60,7 @@
5760
- Added a new optional Split Filter configuration option. This allows the SDK and Split services to only synchronize the flags in the specified flag sets, avoiding unused or unwanted flags from being synced on the SDK instance, bringing all the benefits from a reduced payload.
5861
- Note: Only applicable when the SDK is in charge of the rollout data synchronization. When not applicable, the SDK will log a warning on init.
5962
- Added `sets` property to the `SplitView` object returned by the `split` and `splits` methods of the SDK manager to expose flag sets on flag views.
60-
- Bugfixing - Fixed SDK key validation in NodeJS to ensure the SDK_READY_TIMED_OUT event is emitted when a client-side type SDK key is provided instead of a server-side one (Related to issue https://github.com/splitio/javascript-client/issues/768).
63+
- Bugfixing - Fixed SDK key validation in Node.js to ensure the SDK_READY_TIMED_OUT event is emitted when a client-side type SDK key is provided instead of a server-side one (Related to issue https://github.com/splitio/javascript-client/issues/768).
6164

6265
1.10.0 (October 20, 2023)
6366
- Added `defaultTreatment` property to the `SplitView` object returned by the `split` and `splits` methods of the SDK manager (Related to issue https://github.com/splitio/javascript-commons/issues/225).
@@ -135,7 +138,7 @@
135138
1.3.0 (April 6, 2022)
136139
- Added user consent feature to allow delaying or disabling the data tracking from SDK until user consent is explicitly granted or declined. Read more in our docs.
137140
- Added `scheduler.impressionsQueueSize` property to SDK configuration to limit the amount of impressions tracked in memory. Read more in our docs.
138-
- Added support to accept TLS configuration options to the Redis storage in NodeJS. Read more in our docs.
141+
- Added support to accept TLS configuration options to the Redis storage in Node.js. Read more in our docs.
139142
- Updated format for MySegments keys in LocalStorage, keeping backwards compatibility (issue https://github.com/splitio/javascript-client/issues/638).
140143
- Updated some modules due to general polishing and refactors, including updates in some log messages.
141144
- Updated some dependencies for vulnerability fixes.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Split has built and maintains SDKs for:
3333
* Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK)
3434
* JavaScript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
3535
* JavaScript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK)
36-
* Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
36+
* Node.js [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
3737
* PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK)
3838
* PHP thin-client [Github](https://github.com/splitio/php-thin-client) [Docs](https://help.split.io/hc/en-us/articles/18305128673933-PHP-Thin-Client-SDK)
3939
* Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK)

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/listeners/__tests__/node.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const processOnSpy = jest.spyOn(process, 'on');
55
const processRemoveListenerSpy = jest.spyOn(process, 'removeListener');
66
const processKillSpy = jest.spyOn(process, 'kill').mockImplementation(() => true);
77

8-
test('Node JS listener / Signal Listener class methods and start/stop functionality', () => {
8+
test('NodeSignalListener / Signal Listener class methods and start/stop functionality', () => {
99

1010
const syncManagerMock = { flush: jest.fn() }; // @ts-expect-error
1111
const listener = new NodeSignalListener(syncManagerMock, fullSettings);
@@ -25,7 +25,7 @@ test('Node JS listener / Signal Listener class methods and start/stop functional
2525
expect(processRemoveListenerSpy.mock.calls).toEqual([['SIGTERM', listener._sigtermHandler]]);
2626
});
2727

28-
test('Node JS listener / Signal Listener SIGTERM callback with sync handler', () => {
28+
test('NodeSignalListener / Signal Listener SIGTERM callback with sync handler', () => {
2929

3030
const syncManagerMock = { flush: jest.fn() }; // @ts-expect-error
3131
const listener = new NodeSignalListener(syncManagerMock, fullSettings);
@@ -55,7 +55,7 @@ test('Node JS listener / Signal Listener SIGTERM callback with sync handler', ()
5555
processKillSpy.mockClear();
5656
});
5757

58-
test('Node JS listener / Signal Listener SIGTERM callback with sync handler that throws an error', () => {
58+
test('NodeSignalListener / Signal Listener SIGTERM callback with sync handler that throws an error', () => {
5959
const syncManagerMock = { flush: jest.fn(() => { throw 'some error'; }) }; // @ts-expect-error
6060
const listener = new NodeSignalListener(syncManagerMock, fullSettings);
6161

@@ -85,7 +85,7 @@ test('Node JS listener / Signal Listener SIGTERM callback with sync handler that
8585
processKillSpy.mockClear();
8686
});
8787

88-
test('Node JS listener / Signal Listener SIGTERM callback with async handler', async () => {
88+
test('NodeSignalListener / Signal Listener SIGTERM callback with async handler', async () => {
8989

9090
const fakePromise = new Promise<void>(res => {
9191
setTimeout(() => {
@@ -125,7 +125,7 @@ test('Node JS listener / Signal Listener SIGTERM callback with async handler', a
125125
});
126126
});
127127

128-
test('Node JS listener / Signal Listener SIGTERM callback with async handler that throws an error', async () => {
128+
test('NodeSignalListener / Signal Listener SIGTERM callback with async handler that throws an error', async () => {
129129

130130
const fakePromise = new Promise<void>((res, rej) => {
131131
setTimeout(() => {

src/listeners/node.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// @TODO eventually migrate to JS-Node-SDK package.
1+
// @TODO eventually migrate to Node.js SDK package.
22
import { ISignalListener } from './types';
33
import { thenable } from '../utils/promise/thenable';
44
import { MaybeThenable } from '../dtos/types';
@@ -25,7 +25,7 @@ export class NodeSignalListener implements ISignalListener {
2525
syncManager: ISyncManager | undefined, // private handler: () => MaybeThenable<void>,
2626
settings: ISettings
2727
) {
28-
// @TODO review handler logic when implementing Node SDK
28+
// @TODO review handler logic when implementing Node.js SDK
2929
this.handler = function () {
3030
if (syncManager) {
3131
// syncManager.stop();

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/sdkFactory/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export interface IPlatform {
2828
*/
2929
getEventSource?: (settings: ISettings) => (IEventSourceConstructor | undefined)
3030
/**
31-
* EventEmitter constructor, like NodeJS.EventEmitter or a polyfill.
31+
* EventEmitter constructor, like Node.js EventEmitter or a polyfill.
3232
*/
3333
EventEmitter: new () => SplitIO.IEventEmitter,
3434
/**
@@ -104,7 +104,7 @@ export interface ISdkFactoryParams {
104104
filterAdapterFactory?: () => IFilterAdapter
105105

106106
// Optional signal listener constructor. Used to handle special app states, like shutdown, app paused or resumed.
107-
// Pass only if `syncManager` (used by Node listener) and `splitApi` (used by Browser listener) are passed.
107+
// Pass only if `syncManager` (used by NodeSignalListener) and `splitApi` (used by Browser listener) are passed.
108108
SignalListener?: new (
109109
syncManager: ISyncManager | undefined, // Used by NodeSignalListener to flush data, and by BrowserSignalListener to close streaming connection.
110110
settings: ISettings, // Used by BrowserSignalListener

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

0 commit comments

Comments
 (0)