Skip to content

Commit 3979c59

Browse files
Merge pull request #474 from splitio/development
release 2.12.0
2 parents 3aabacc + 9fc9461 commit 3979c59

16 files changed

+146
-138
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2.12.0 (February 24, 2026)
2+
- Added support for ioredis v5.
3+
14
2.11.0 (January 28, 2026)
25
- Added functionality to provide metadata alongside SDK update and READY events. Read more in our docs.
36

package-lock.json

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@splitsoftware/splitio-commons",
3-
"version": "2.11.0",
3+
"version": "2.12.0",
44
"description": "Split JavaScript SDK common components",
55
"main": "cjs/index.js",
66
"module": "esm/index.js",
@@ -49,7 +49,7 @@
4949
"tslib": "^2.3.1"
5050
},
5151
"peerDependencies": {
52-
"ioredis": "^4.28.0"
52+
"ioredis": "^4.28.0 || ^5.0.0"
5353
},
5454
"peerDependenciesMeta": {
5555
"ioredis": {
@@ -68,7 +68,7 @@
6868
"eslint-plugin-import": "^2.25.3",
6969
"eslint-plugin-tsdoc": "^0.3.0",
7070
"fetch-mock": "^9.11.0",
71-
"ioredis": "^4.28.0",
71+
"ioredis": "^5.0.0",
7272
"jest": "^27.2.3",
7373
"jest-localstorage-mock": "^2.4.3",
7474
"lodash": "^4.17.21",

src/storages/inRedis/EventsCacheInRedis.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class EventsCacheInRedis implements IEventsCacheAsync {
3131
)
3232
// We use boolean values to signal successful queueing
3333
.then(() => true)
34-
.catch(err => {
34+
.catch((err: unknown) => {
3535
this.log.error(`${LOG_PREFIX}Error adding event to queue: ${err}.`);
3636
return false;
3737
});
@@ -65,9 +65,9 @@ export class EventsCacheInRedis implements IEventsCacheAsync {
6565
* It is the submitter responsability to handle that.
6666
*/
6767
popNWithMetadata(count: number): Promise<StoredEventWithMetadata[]> {
68-
return this.redis.lrange(this.key, 0, count - 1).then(items => {
68+
return this.redis.lrange(this.key, 0, count - 1).then((items: string[]) => {
6969
return this.redis.ltrim(this.key, items.length, -1).then(() => {
70-
return items.map(item => JSON.parse(item) as StoredEventWithMetadata);
70+
return items.map((item: string) => JSON.parse(item) as StoredEventWithMetadata);
7171
});
7272
});
7373
}

src/storages/inRedis/ImpressionCountsCacheInRedis.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ export class ImpressionCountsCacheInRedis extends ImpressionCountsCacheInMemory
3232
pipeline.hincrby(this.key, key, counts[key]);
3333
});
3434
return pipeline.exec()
35-
.then(data => {
35+
.then((data: [Error | null, unknown][] | null) => {
3636
// If this is the creation of the key on Redis, set the expiration for it in 3600 seconds.
37-
if (data.length && data.length === keys.length) {
37+
if (data && data.length && data.length === keys.length) {
3838
return this.redis.expire(this.key, TTL_REFRESH);
3939
}
4040
})
41-
.catch(err => {
41+
.catch((err: unknown) => {
4242
this.log.error(`${LOG_PREFIX}Error in impression counts pipeline: ${err}.`);
4343
return false;
4444
});
@@ -56,14 +56,14 @@ export class ImpressionCountsCacheInRedis extends ImpressionCountsCacheInMemory
5656
// Async consumer API, used by synchronizer
5757
getImpressionsCount(): Promise<ImpressionCountsPayload | undefined> {
5858
return this.redis.hgetall(this.key)
59-
.then(counts => {
59+
.then((counts: Record<string, string>) => {
6060
if (!Object.keys(counts).length) return undefined;
6161

6262
this.redis.del(this.key).catch(() => { /* no-op */ });
6363

6464
const pf: ImpressionCountsPayload['pf'] = [];
6565

66-
forOwn(counts, (count, key) => {
66+
forOwn(counts, (count: string, key) => {
6767
const nameAndTime = key.split('::');
6868
if (nameAndTime.length !== 2) {
6969
this.log.error(`${LOG_PREFIX}Error spliting key ${key}`);

src/storages/inRedis/ImpressionsCacheInRedis.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export class ImpressionsCacheInRedis implements IImpressionsCacheAsync {
2525
track(impressions: SplitIO.ImpressionDTO[]): Promise<void> { // @ts-ignore
2626
return this.redis.rpush(
2727
this.key,
28-
impressionsToJSON(impressions, this.metadata),
29-
).then(queuedCount => {
28+
...impressionsToJSON(impressions, this.metadata),
29+
).then((queuedCount: number) => {
3030
// If this is the creation of the key on Redis, set the expiration for it in 1hr.
3131
if (queuedCount === impressions.length) {
3232
return this.redis.expire(this.key, IMPRESSIONS_TTL_REFRESH);
@@ -45,15 +45,15 @@ export class ImpressionsCacheInRedis implements IImpressionsCacheAsync {
4545
}
4646

4747
popNWithMetadata(count: number): Promise<StoredImpressionWithMetadata[]> {
48-
return this.redis.lrange(this.key, 0, count - 1).then(items => {
48+
return this.redis.lrange(this.key, 0, count - 1).then((items: string[]) => {
4949
return this.redis.ltrim(this.key, items.length, -1).then(() => {
5050
// This operation will simply do nothing if the key no longer exists (queue is empty)
5151
// It's only done in the "successful" exit path so that the TTL is not overriden if impressons weren't
5252
// popped correctly. This will result in impressions getting lost but will prevent the queue from taking
5353
// a huge amount of memory.
5454
this.redis.expire(this.key, IMPRESSIONS_TTL_REFRESH).catch(() => { }); // noop catch handler
5555

56-
return items.map(item => JSON.parse(item) as StoredImpressionWithMetadata);
56+
return items.map((item: string) => JSON.parse(item) as StoredImpressionWithMetadata);
5757
});
5858
});
5959
}

src/storages/inRedis/RBSegmentsCacheInRedis.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ export class RBSegmentsCacheInRedis implements IRBSegmentsCacheAsync {
2121

2222
get(name: string): Promise<IRBSegment | null> {
2323
return this.redis.get(this.keys.buildRBSegmentKey(name))
24-
.then(maybeRBSegment => maybeRBSegment && JSON.parse(maybeRBSegment));
24+
.then((maybeRBSegment: string | null) => maybeRBSegment && JSON.parse(maybeRBSegment));
2525
}
2626

2727
private getNames(): Promise<string[]> {
2828
return this.redis.keys(this.keys.searchPatternForRBSegmentKeys()).then(
29-
(listOfKeys) => listOfKeys.map(this.keys.extractKey)
29+
(listOfKeys: string[]) => listOfKeys.map(this.keys.extractKey)
3030
);
3131
}
3232

@@ -47,7 +47,7 @@ export class RBSegmentsCacheInRedis implements IRBSegmentsCacheAsync {
4747
})),
4848
Promise.all(toRemove.map(toRemove => {
4949
const key = this.keys.buildRBSegmentKey(toRemove.name);
50-
return this.redis.del(key).then(status => status === 1);
50+
return this.redis.del(key).then((status: number) => status === 1);
5151
}))
5252
]).then(([, added, removed]) => {
5353
return added.some(result => result) || removed.some(result => result);
@@ -56,7 +56,7 @@ export class RBSegmentsCacheInRedis implements IRBSegmentsCacheAsync {
5656

5757
setChangeNumber(changeNumber: number) {
5858
return this.redis.set(this.keys.buildRBSegmentsTillKey(), changeNumber + '').then(
59-
status => status === 'OK'
59+
(status: string | null) => status === 'OK'
6060
);
6161
}
6262

@@ -65,7 +65,7 @@ export class RBSegmentsCacheInRedis implements IRBSegmentsCacheAsync {
6565
const i = parseInt(value as string, 10);
6666

6767
return isNaNNumber(i) ? -1 : i;
68-
}).catch((e) => {
68+
}).catch((e: unknown) => {
6969
this.log.error(LOG_PREFIX + 'Could not retrieve changeNumber from storage. Error: ' + e);
7070
return -1;
7171
});

0 commit comments

Comments
 (0)