Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ pipeline:
spec:
shell: Sh
command: npm run test
- step:
type: Run
name: ioredis peer dependency matrix
identifier: ioredis_matrix
spec:
shell: Sh
command: |-
set -e
for version in 4 5; do
echo "--- Testing against ioredis v$version ---"
npm install --no-save --no-audit --no-fund "ioredis@$version"
npx jest src/storages/inRedis
done
npm ci
- step:
type: Run
name: npm run build
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2.13.0 (September 24, 2026)
- Added support for ioredis v6 (Related to issue https://github.com/splitio/javascript-client/issues/951). Note that ioredis v6 requires Node.js 20 or above; stay on ioredis v4 or v5 for older Node.js versions.
- Removed the `@types/ioredis` dependency, which is no longer required since the public type definitions don't depend on ioredis types. The `@types/node` dependency, previously installed transitively by `@types/ioredis`, is now declared explicitly, since the public type definitions use Node.js types for the `agent` and `tls` options.

2.12.2 (September 23, 2026)
- Updated some transitive dependencies for vulnerability fixes.

Expand Down
55 changes: 16 additions & 39 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splitsoftware/splitio-commons",
"version": "2.12.2",
"version": "2.13.0",
"description": "Split JavaScript SDK common components",
"main": "cjs/index.js",
"module": "esm/index.js",
Expand Down Expand Up @@ -45,19 +45,18 @@
"bugs": "https://github.com/splitio/javascript-commons/issues",
"homepage": "https://github.com/splitio/javascript-commons#readme",
"dependencies": {
"@types/ioredis": "^4.28.0",
"@types/node": ">=14.0.0",
"tslib": "^2.3.1"
},
"peerDependencies": {
"ioredis": "^4.28.0 || ^5.0.0"
"ioredis": "^4.28.0 || ^5.0.0 || ^6.0.0"
},
"peerDependenciesMeta": {
"ioredis": {
"optional": true
}
},
"devDependencies": {
"@types/ioredis": "^4.28.0",
"@types/jest": "^27.0.0",
"@types/lodash": "^4.14.162",
"@typescript-eslint/eslint-plugin": "^7.18.0",
Expand All @@ -68,7 +67,7 @@
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-tsdoc": "^0.3.0",
"fetch-mock": "^9.11.0",
"ioredis": "^5.0.0",
"ioredis": "^6.0.0",
"jest": "^27.2.3",
"jest-localstorage-mock": "^2.4.3",
"lodash": "^4.17.21",
Expand Down
13 changes: 8 additions & 5 deletions src/storages/inRedis/RedisAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Dynamically require ioredis to prevent strict TypeScript binding
// and handle module export differences between v4 and v5.
// and handle module export differences between v4 and later major versions.
let RedisConstructor: any;
try {
const ioredisLib = require('ioredis');
RedisConstructor = ioredisLib.default || ioredisLib;
} catch (e) {
// If we reach here, the peer dependency is missing
throw new Error('ioredis is missing. Please install ioredis v4 or v5.');
throw new Error('ioredis is missing. Please install ioredis v4, v5 or v6.');
}

import { ILogger } from '../../logger/types';
Expand All @@ -31,9 +31,12 @@ const DEFAULT_LIBRARY_OPTIONS = {
enableOfflineQueue: false,
connectTimeout: DEFAULT_OPTIONS.connectionTimeout,
lazyConnect: false,
// CRITICAL: v5 defaults this to 0 (disabled), which breaks dynamic clusters.
// v4 defaulted to 5000. We explicitly set it here to ensure v5 works like v4.
// CRITICAL: v5 and v6 default this to 0 (disabled), which breaks dynamic clusters.
// v4 defaulted to 5000. We explicitly set it here to ensure v5 and v6 work like v4.
slotsRefreshInterval: 5000,
// v6 defaults to RESP3 (`protocol: 3`). The SDK doesn't use any RESP3 feature,
// so we stick to RESP2 to keep the v4 and v5 behavior. Ignored by v4 and v5.
protocol: 2,
};

interface IRedisCommand {
Expand All @@ -45,7 +48,7 @@ interface IRedisCommand {

/**
* Redis adapter on top of the library of choice (written with ioredis) for some extra control.
* Refactored to use Composition instead of Inheritance to support both v4 and v5.
* Refactored to use Composition instead of Inheritance to support v4, v5 and v6.
*/
export class RedisAdapter {
// eslint-disable-next-line no-undef -- Index signature to allow proxying dynamic ioredis methods without TS errors
Expand Down
6 changes: 3 additions & 3 deletions src/storages/inRedis/__tests__/RedisAdapter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ describe('STORAGE Redis Adapter', () => {
// Keep in mind we're storing the arguments object, not a true array.
expect(constructorParams.length).toBe(2); // In this signature, the constructor receives two params.
expect(constructorParams[0]).toBe(redisUrl); // When we use the Redis URL, that should be the first parameter passed to ioredis constructor
expect(constructorParams[1]).toEqual({ enableOfflineQueue: false, connectTimeout: 123, lazyConnect: false, slotsRefreshInterval: 5000, tls: { ca: 'ca' } }); // and the second parameter would be the default settings for the lib.
expect(constructorParams[1]).toEqual({ enableOfflineQueue: false, connectTimeout: 123, lazyConnect: false, slotsRefreshInterval: 5000, protocol: 2, tls: { ca: 'ca' } }); // and the second parameter would be the default settings for the lib.

new RedisAdapter(loggerMock, {
...redisParams,
Expand All @@ -121,7 +121,7 @@ describe('STORAGE Redis Adapter', () => {

expect(constructorParams.length).toBe(1); // In this signature, the constructor receives one param.
// we keep "pass" instead of "password" on our settings API to be backwards compatible.
expect(constructorParams[0]).toEqual({ host: redisParams.host, port: redisParams.port, db: redisParams.db, password: redisParams.pass, enableOfflineQueue: false, connectTimeout: 123, lazyConnect: false, slotsRefreshInterval: 5000, tls: { ca: 'ca' } }); // If we send all the redis params separate, it will pass one object to the library containing that and the rest of the options.
expect(constructorParams[0]).toEqual({ host: redisParams.host, port: redisParams.port, db: redisParams.db, password: redisParams.pass, enableOfflineQueue: false, connectTimeout: 123, lazyConnect: false, slotsRefreshInterval: 5000, protocol: 2, tls: { ca: 'ca' } }); // If we send all the redis params separate, it will pass one object to the library containing that and the rest of the options.

new RedisAdapter(loggerMock, {
...redisParams,
Expand All @@ -133,7 +133,7 @@ describe('STORAGE Redis Adapter', () => {

expect(constructorParams.length).toBe(2); // In this signature, the constructor receives two params.
expect(constructorParams[0]).toBe(redisUrl); // When we use the Redis URL, even if we specified all the other params one by one the URL takes precedence, so that should be the first parameter passed to ioredis constructor
expect(constructorParams[1]).toEqual({ enableOfflineQueue: false, connectTimeout: 10000, lazyConnect: false, slotsRefreshInterval: 5000, tls: { ca: 'ca' } }); // and the second parameter would be the default settings for the lib.
expect(constructorParams[1]).toEqual({ enableOfflineQueue: false, connectTimeout: 10000, lazyConnect: false, slotsRefreshInterval: 5000, protocol: 2, tls: { ca: 'ca' } }); // and the second parameter would be the default settings for the lib.
});

test('static method - _defineOptions', () => {
Expand Down
4 changes: 2 additions & 2 deletions types/splitio.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Type definitions for Split Software SDKs
// Project: https://www.split.io/

import type { RedisOptions } from 'ioredis';
import type { ConnectionOptions } from 'tls';
import type { RequestOptions } from 'http';

export as namespace SplitIO;
Expand Down Expand Up @@ -1713,7 +1713,7 @@ declare namespace SplitIO {
*
* @defaultValue `undefined`
*/
tls?: RedisOptions['tls'];
tls?: ConnectionOptions;
};
/**
* Optional prefix to prevent any kind of data collision between SDK versions.
Expand Down