Skip to content

Commit 34fa535

Browse files
Merge pull request #899 from splitio/fallback-treatment
Release 11.8.0
2 parents 105e4fc + 7495443 commit 34fa535

File tree

15 files changed

+370
-46
lines changed

15 files changed

+370
-46
lines changed

CHANGES.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
11.8.0 (October 30, 2025)
2+
- Added new configuration for Fallback Treatments, which allows setting a treatment value and optional config to be returned in place of "control", either globally or by flag. Read more in our docs.
3+
- Added `client.getStatus()` method to retrieve the client readiness status properties (`isReady`, `isReadyFromCache`, etc).
4+
- 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.
5+
- Updated the SDK_READY_FROM_CACHE event to be emitted alongside the SDK_READY event if it hasn’t already been emitted.
6+
- Updated @splitsoftware/splitio-commons package to version 2.8.0.
7+
18
11.7.1 (October 8, 2025)
29
- Bugfix - Updated @splitsoftware/splitio-commons package to version 2.7.1, which fixes the `debug` option to support log levels when the `logger` option is used.
310

karma/e2e.online.karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const assign = require('lodash/assign');
22

3-
module.exports = function(config) {
3+
module.exports = function (config) {
44
'use strict';
55

66
config.set(assign({}, require('./config'), {

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@splitsoftware/splitio",
3-
"version": "11.7.1",
3+
"version": "11.8.0",
44
"description": "Split SDK",
55
"files": [
66
"README.md",
@@ -38,7 +38,7 @@
3838
"node": ">=14.0.0"
3939
},
4040
"dependencies": {
41-
"@splitsoftware/splitio-commons": "2.7.9-rc.1",
41+
"@splitsoftware/splitio-commons": "2.8.0",
4242
"bloom-filters": "^3.0.4",
4343
"ioredis": "^4.28.0",
4444
"js-yaml": "^3.13.1",

src/__tests__/browserSuites/ready-from-cache-async-wrapper.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,17 @@ export default function (fetchMock, assert) {
7070
t.end();
7171
});
7272
client.once(client.Event.SDK_READY_FROM_CACHE, () => {
73-
t.true(client.__getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY');
73+
t.true(client.getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY');
7474
});
7575

7676
client.on(client.Event.SDK_READY, () => {
77-
t.true(client.__getStatus().isReadyFromCache, 'Client should emit SDK_READY and it should be ready from cache');
77+
t.true(client.getStatus().isReadyFromCache, 'Client should emit SDK_READY and it should be ready from cache');
7878
});
7979
client2.on(client.Event.SDK_READY, () => {
80-
t.true(client2.__getStatus().isReadyFromCache, 'Non-default client should emit SDK_READY and it should be ready from cache');
80+
t.true(client2.getStatus().isReadyFromCache, 'Non-default client should emit SDK_READY and it should be ready from cache');
8181
});
8282
client3.on(client.Event.SDK_READY, () => {
83-
t.true(client2.__getStatus().isReadyFromCache, 'Non-default client should emit SDK_READY and it should be ready from cache');
83+
t.true(client2.getStatus().isReadyFromCache, 'Non-default client should emit SDK_READY and it should be ready from cache');
8484
});
8585

8686
});
@@ -356,7 +356,7 @@ export default function (fetchMock, assert) {
356356
let manager = splitio.manager();
357357

358358
client.once(client.Event.SDK_READY_FROM_CACHE, () => {
359-
t.true(client.__getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY, because clearOnInit is true');
359+
t.true(client.getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY, because clearOnInit is true');
360360
});
361361

362362
await client.whenReady();
@@ -400,7 +400,7 @@ export default function (fetchMock, assert) {
400400
manager = splitio.manager();
401401

402402
client.once(client.Event.SDK_READY_FROM_CACHE, () => {
403-
t.true(client.__getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY, because clearOnInit is true');
403+
t.true(client.getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY, because clearOnInit is true');
404404
});
405405

406406
await new Promise(res => client.once(client.Event.SDK_READY, res));

src/__tests__/browserSuites/ready-from-cache.spec.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,17 @@ export default function (fetchMock, assert) {
142142
t.end();
143143
});
144144
client.once(client.Event.SDK_READY_FROM_CACHE, () => {
145-
t.true(client.__getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY');
145+
t.true(client.getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY');
146146
});
147147

148148
client.on(client.Event.SDK_READY, () => {
149-
t.true(client.__getStatus().isReadyFromCache, 'Client should emit SDK_READY and it should be ready from cache');
149+
t.true(client.getStatus().isReadyFromCache, 'Client should emit SDK_READY and it should be ready from cache');
150150
});
151151
client2.on(client.Event.SDK_READY, () => {
152-
t.true(client2.__getStatus().isReadyFromCache, 'Non-default client should emit SDK_READY and it should be ready from cache');
152+
t.true(client2.getStatus().isReadyFromCache, 'Non-default client should emit SDK_READY and it should be ready from cache');
153153
});
154154
client3.on(client.Event.SDK_READY, () => {
155-
t.true(client2.__getStatus().isReadyFromCache, 'Non-default client should emit SDK_READY and it should be ready from cache');
155+
t.true(client2.getStatus().isReadyFromCache, 'Non-default client should emit SDK_READY and it should be ready from cache');
156156
});
157157

158158
});
@@ -331,7 +331,7 @@ export default function (fetchMock, assert) {
331331

332332
client.on(client.Event.SDK_READY_FROM_CACHE, () => {
333333
t.true(Date.now() - startTime < 400, 'It should emit SDK_READY_FROM_CACHE on every client if there was data in the cache and we subscribe on time. Should be considerably faster than actual readiness from the cloud.');
334-
t.false(client.__getStatus().isReady, 'It should not be ready yet');
334+
t.false(client.getStatus().isReady, 'It should not be ready yet');
335335

336336
t.equal(client.getTreatment('always_on'), 'off', 'It should evaluate treatments with data from cache instead of control due to Input Validation');
337337

@@ -515,13 +515,13 @@ export default function (fetchMock, assert) {
515515
});
516516
});
517517

518-
assert.test(t => { // Testing when we start with initial rollout plan data and sync storage type (is ready from cache immediately)
518+
assert.test(async t => { // Testing when we start with initial rollout plan data and sync storage type (is ready from cache immediately)
519519
const testUrls = {
520520
sdk: 'https://sdk.baseurl/readyFromCacheWithInitialRolloutPlan',
521521
events: 'https://events.baseurl/readyFromCacheWithInitialRolloutPlan'
522522
};
523523

524-
t.plan(5);
524+
t.plan(6);
525525

526526
fetchMock.getOnce(testUrls.sdk + '/splitChanges?s=1.3&since=25&rbSince=-1', { status: 200, body: { ff: { ...splitChangesMock1.ff, s: 25 } } });
527527
fetchMock.getOnce(testUrls.sdk + '/memberships/nicolas%40split.io', { status: 200, body: membershipsNicolas });
@@ -552,7 +552,7 @@ export default function (fetchMock, assert) {
552552
const client = splitio.client();
553553
const client2 = splitio.client('emi@split.io');
554554

555-
t.equal(client.__getStatus().isReadyFromCache, true, 'Client is ready from cache');
555+
t.equal(client.getStatus().isReadyFromCache, true, 'Client is ready from cache');
556556

557557
t.equal(client.getTreatment('always_on'), 'off', 'It should evaluate treatments with data from cache. Key without memberships');
558558
t.equal(client2.getTreatment('always_on'), 'on', 'It should evaluate treatments with data from cache. Key with memberships');
@@ -577,6 +577,10 @@ export default function (fetchMock, assert) {
577577
t.end();
578578
});
579579
});
580+
581+
const startTime = Date.now();
582+
await client.whenReadyFromCache();
583+
t.true(nearlyEqual(Date.now() - startTime, 0), 'whenReadyFromCache should be resolved immediately');
580584
});
581585

582586
/** Fetch specific splits **/
@@ -613,7 +617,7 @@ export default function (fetchMock, assert) {
613617
const manager = splitio.manager();
614618

615619
client.once(client.Event.SDK_READY_FROM_CACHE, () => {
616-
t.true(client.__getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY');
620+
t.true(client.getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY');
617621
});
618622

619623
client.once(client.Event.SDK_READY, () => {
@@ -657,7 +661,7 @@ export default function (fetchMock, assert) {
657661
const manager = splitio.manager();
658662

659663
client.once(client.Event.SDK_READY_FROM_CACHE, () => {
660-
t.true(client.__getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY');
664+
t.true(client.getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY');
661665
});
662666

663667
client.once(client.Event.SDK_READY, () => {
@@ -758,7 +762,7 @@ export default function (fetchMock, assert) {
758762
const manager = splitio.manager();
759763

760764
client.once(client.Event.SDK_READY_FROM_CACHE, () => {
761-
t.true(client.__getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY');
765+
t.true(client.getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY');
762766
});
763767

764768
client.once(client.Event.SDK_READY, () => {
@@ -819,7 +823,7 @@ export default function (fetchMock, assert) {
819823
const manager = splitio.manager();
820824

821825
client.once(client.Event.SDK_READY_FROM_CACHE, () => {
822-
t.true(client.__getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY');
826+
t.true(client.getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY');
823827
});
824828

825829
client.once(client.Event.SDK_READY, () => {
@@ -919,7 +923,7 @@ export default function (fetchMock, assert) {
919923
let manager = splitio.manager();
920924

921925
client.once(client.Event.SDK_READY_FROM_CACHE, () => {
922-
t.true(client.__getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY, because clearOnInit is true');
926+
t.true(client.getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY, because clearOnInit is true');
923927
});
924928

925929
await client.whenReady();
@@ -959,7 +963,7 @@ export default function (fetchMock, assert) {
959963
manager = splitio.manager();
960964

961965
client.once(client.Event.SDK_READY_FROM_CACHE, () => {
962-
t.true(client.__getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY, because clearOnInit is true');
966+
t.true(client.getStatus().isReady, 'Client should emit SDK_READY_FROM_CACHE alongside SDK_READY, because clearOnInit is true');
963967
});
964968

965969
await new Promise(res => client.once(client.Event.SDK_READY, res));

src/__tests__/errorCatching/browser.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ tape('Error catching on callbacks - Browsers', assert => {
9191
}
9292

9393
client.on(client.Event.SDK_READY_TIMED_OUT, () => {
94-
assert.true(client.__getStatus().hasTimedout); // SDK status should be already updated
94+
assert.true(client.getStatus().hasTimedout); // SDK status should be already updated
9595
attachErrorHandlerIfApplicable();
9696
null.willThrowForTimedOut();
9797
});
9898

9999
client.once(client.Event.SDK_READY, () => {
100-
assert.true(client.__getStatus().isReady); // SDK status should be already updated
100+
assert.true(client.getStatus().isReady); // SDK status should be already updated
101101
attachErrorHandlerIfApplicable();
102102
null.willThrowForReady();
103103
});
@@ -108,7 +108,7 @@ tape('Error catching on callbacks - Browsers', assert => {
108108
});
109109

110110
client.once(client.Event.SDK_READY_FROM_CACHE, () => {
111-
assert.true(client.__getStatus().isReadyFromCache); // SDK status should be already updated
111+
assert.true(client.getStatus().isReadyFromCache); // SDK status should be already updated
112112
attachErrorHandlerIfApplicable();
113113
null.willThrowForReadyFromCache();
114114
});

0 commit comments

Comments
 (0)