You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGES.txt
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
2.8.0 (October XX, 2025)
2
+
- Added `client.whenReady()` and `client.whenReadyFromCache()` methods to replace the deprecated `client.ready()` method, which has an issue causing the returned promise to hang when using async/await syntax if it was rejected.
2
3
- Updated the SDK_READY_FROM_CACHE event to be emitted alongside the SDK_READY event if it hasn’t already been emitted.
[c.SUBMITTERS_PUSH_RETRY,c.LOG_PREFIX_SYNC_SUBMITTERS+'Failed to push %s, keeping data to retry on next iteration. Reason: %s.'],
16
16
// client status
17
17
[c.CLIENT_NOT_READY_FROM_CACHE,'%s: the SDK is not ready to evaluate. Results may be incorrect%s. Make sure to wait for SDK readiness before using this method.'],
18
-
[c.CLIENT_NO_LISTENER,'No listeners for SDK Readiness detected. Incorrect control treatments could have been logged if you called getTreatment/s while the SDK was not yet ready.'],
18
+
[c.CLIENT_NO_LISTENER,'No listeners for SDK_READY event detected. Incorrect control treatments could have been logged if you called getTreatment/s while the SDK was not yet synchronized with the backend.'],
19
19
// input validation
20
20
[c.WARN_SETTING_NULL,'%s: Property "%s" is of invalid type. Setting value to null.'],
21
21
[c.WARN_TRIMMING_PROPERTIES,'%s: more than 300 properties were provided. Some of them will be trimmed when processed.'],
expect(sdkReadyResolvePromiseCall[0]).toBe(SDK_READY);// A one time only subscription is on the SDK_READY event, for resolving the full blown ready promise and to check for callbacks warning.
71
-
expect(sdkReadyRejectPromiseCall[0]).toBe(SDK_READY_TIMED_OUT);// A one time only subscription is also on the SDK_READY_TIMED_OUT event, for rejecting the full blown ready promise.
72
-
expect(sdkReadyFromCacheListenersCheckCall[0]).toBe(SDK_READY_FROM_CACHE);// A one time only subscription is on the SDK_READY_FROM_CACHE event, to log the event and update internal state.
84
+
expect(sdkReadyResolvePromiseCall[0]).toBe(SDK_READY);// A one time only subscription is on the SDK_READY event
85
+
expect(sdkReadyRejectPromiseCall[0]).toBe(SDK_READY_TIMED_OUT);// A one time only subscription is also on the SDK_READY_TIMED_OUT event
86
+
expect(sdkReadyFromCacheListenersCheckCall[0]).toBe(SDK_READY_FROM_CACHE);// A one time only subscription is on the SDK_READY_FROM_CACHE event
73
87
74
88
expect(gateMock.on).toBeCalledTimes(2);// It should also add two persistent listeners
expect(loggerMock.warn).toBeCalledTimes(1);// If the SDK_READY event fires and we have no callbacks for it (neither event nor ready promise) we get a warning.
115
+
expect(loggerMock.warn).toBeCalledTimes(1);// If the SDK_READY event fires and we have no callbacks for it (neither event nor whenReady promise) we get a warning.
102
116
expect(loggerMock.warn).toBeCalledWith(CLIENT_NO_LISTENER);// Telling us there were no listeners and evaluations before this point may have been incorrect.
103
117
104
118
expect(loggerMock.info).toBeCalledTimes(1);// If the SDK_READY event fires, we get a info message.
expect(loggerMock.warn).toBeCalledWith(CLIENT_NO_LISTENER);// We should get a warning if the SDK get's ready before calling the whenReady method or attaching a listener to the ready event
constTIMEOUT_ERROR=newError('Split SDK has emitted SDK_READY_TIMED_OUT event.');
12
+
constTIMEOUT_ERROR=newError(SDK_READY_TIMED_OUT);
13
13
14
14
/**
15
15
* SdkReadinessManager factory, which provides the public status API of SDK clients and manager: ready promise, readiness event emitter and constants (SDK_READY, etc).
@@ -39,6 +39,8 @@ export function sdkReadinessManagerFactory(
Copy file name to clipboardExpand all lines: types/splitio.d.ts
+5-3Lines changed: 5 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -752,7 +752,7 @@ declare namespace SplitIO {
752
752
*/
753
753
getStatus(): ReadinessStatus;
754
754
/**
755
-
* Returns a promise that resolves once the SDK has finished synchronizing with the backend (`SDK_READY` event emitted) or rejected if the SDK has timedout (`SDK_READY_TIMED_OUT` event emitted).
755
+
* Returns a promise that resolves when the SDK has finished initial synchronization with the backend (`SDK_READY` event emitted), or rejected if the SDK has timedout (`SDK_READY_TIMED_OUT` event emitted).
756
756
* As it's meant to provide similar flexibility to the event approach, given that the SDK might be eventually ready after a timeout event, the `ready` method will return a resolved promise once the SDK is ready.
757
757
*
758
758
* Caveats: the method was designed to avoid an unhandled Promise rejection if the rejection case is not handled, so that `onRejected` handler is optional when using promises.
@@ -771,15 +771,17 @@ declare namespace SplitIO {
771
771
*/
772
772
ready(): Promise<void>;
773
773
/**
774
-
* Returns a promise that resolves once the SDK is ready for evaluations using cached data synchronized with the backend (`SDK_READY` event emitted) or rejected if the SDK has timedout (`SDK_READY_TIMED_OUT` event emitted).
774
+
* Returns a promise that resolves when the SDK has finished initial synchronization with the backend (`SDK_READY` event emitted), or rejected if the SDK has timedout (`SDK_READY_TIMED_OUT` event emitted).
775
775
* As it's meant to provide similar flexibility than event listeners, given that the SDK might be ready after a timeout event, the `whenReady` method will return a resolved promise once the SDK is ready.
776
+
* You must handle the promise rejection to avoid an unhandled promise rejection error, or set the `startup.readyTimeout` configuration option to 0 to avoid the timeout and thus the rejection.
776
777
*
777
778
* @returns A promise that resolves once the SDK_READY event is emitted or rejects if the SDK has timedout.
778
779
*/
779
780
whenReady(): Promise<void>;
780
781
/**
781
-
* Returns a promise that resolves once the SDK is ready for evaluations using cached data which might not yet be synchronized with the backend (`SDK_READY_FROM_CACHE` event emitted) or rejected if the SDK has timedout (`SDK_READY_TIMED_OUT` event emitted).
782
+
* Returns a promise that resolves when the SDK is ready for evaluations using cached data, which might not yet be synchronized with the backend (`SDK_READY_FROM_CACHE` event emitted), or rejected if the SDK has timedout (`SDK_READY_TIMED_OUT` event emitted).
782
783
* As it's meant to provide similar flexibility than event listeners, given that the SDK might be ready from cache after a timeout event, the `whenReadyFromCache` method will return a resolved promise once the SDK is ready from cache.
784
+
* You must handle the promise rejection to avoid an unhandled promise rejection error, or set the `startup.readyTimeout` configuration option to 0 to avoid the timeout and thus the rejection.
783
785
*
784
786
* @returns A promise that resolves once the SDK_READY_FROM_CACHE event is emitted or rejects if the SDK has timedout. The promise resolves with a boolean value that
785
787
* indicates whether the SDK_READY_FROM_CACHE event was emitted together with the SDK_READY event (i.e., the SDK is ready and synchronized with the backend) or not.
0 commit comments