diff --git a/.harness/orgs/PROD/projects/Harness_Split/pipelines/javascript-commons.yaml b/.harness/orgs/PROD/projects/Harness_Split/pipelines/javascript-commons.yaml index 09c4b888..1bf82775 100644 --- a/.harness/orgs/PROD/projects/Harness_Split/pipelines/javascript-commons.yaml +++ b/.harness/orgs/PROD/projects/Harness_Split/pipelines/javascript-commons.yaml @@ -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 diff --git a/CHANGES.txt b/CHANGES.txt index 39429ada..d854a85e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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. diff --git a/package-lock.json b/package-lock.json index 77254a00..2340954a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,18 @@ { "name": "@splitsoftware/splitio-commons", - "version": "2.12.2", + "version": "2.13.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@splitsoftware/splitio-commons", - "version": "2.12.2", + "version": "2.13.0", "license": "Apache-2.0", "dependencies": { - "@types/ioredis": "^4.28.0", + "@types/node": ">=14.0.0", "tslib": "^2.3.1" }, "devDependencies": { - "@types/ioredis": "^4.28.0", "@types/jest": "^27.0.0", "@types/lodash": "^4.14.162", "@typescript-eslint/eslint-plugin": "^7.18.0", @@ -24,7 +23,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", @@ -35,7 +34,7 @@ "typescript": "4.7.4" }, "peerDependencies": { - "ioredis": "^4.28.0 || ^5.0.0" + "ioredis": "^4.28.0 || ^5.0.0 || ^6.0.0" }, "peerDependenciesMeta": { "ioredis": { @@ -659,9 +658,9 @@ "license": "BSD-3-Clause" }, "node_modules/@ioredis/commands": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.10.0.tgz", - "integrity": "sha512-UmeW7z4LfctwoQ5wkhVzgq8tXkreED2xZGpX+Bg+zA+WJFZCT6c062AfCK/Dfk81xZnnwdhJCUMkitihRaoC2Q==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-2.0.0.tgz", + "integrity": "sha512-vrx0AE/T0h7cRZwfo1M39Cr+ZhZrkf0V8mQN75wucKCxCLD9l/VX6no3gFvrLqD1IlG/1LtzWovqEw3t0Vr9zg==", "dev": true, "license": "MIT" }, @@ -1488,15 +1487,6 @@ "@types/node": "*" } }, - "node_modules/@types/ioredis": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@types/ioredis/-/ioredis-4.28.1.tgz", - "integrity": "sha512-raYHPqRWrfnEoym94BY28mG1+tcZqh3dsp2q7x5IyMAAEvIdu+H0X8diASMpncIm+oHyH9dalOeOnGOL/YnuOA==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/istanbul-lib-coverage": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz", @@ -1547,8 +1537,7 @@ "node_modules/@types/node": { "version": "14.14.7", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.7.tgz", - "integrity": "sha512-Zw1vhUSQZYw+7u5dAwNbIA9TuTotpzY/OF7sJM9FqPOF3SPjKnxrjoTktXDZgUjybf4cWVBP7O8wvKdSaGHweg==", - "dev": true + "integrity": "sha512-Zw1vhUSQZYw+7u5dAwNbIA9TuTotpzY/OF7sJM9FqPOF3SPjKnxrjoTktXDZgUjybf4cWVBP7O8wvKdSaGHweg==" }, "node_modules/@types/prettier": { "version": "2.7.3", @@ -4219,22 +4208,21 @@ } }, "node_modules/ioredis": { - "version": "5.11.1", - "resolved": "https://registry.npmjs.org/ioredis/-/ioredis-5.11.1.tgz", - "integrity": "sha512-ehuGcf94bQXhfagULNXrJdfnWO38v070jxSx/qE87Kjzmu2fU7ro5EFAb+OPituLqgfyuQaym5DlrNydW2sJ9A==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/ioredis/-/ioredis-6.0.0.tgz", + "integrity": "sha512-f+Dtubxfpf6KYFq7WVXJoOLn0bk4TJrMrN9SzeE+jrWrCWj7XX3fA6vkryafhADX+GMymRxgDJDOI33COkJc0w==", "dev": true, "license": "MIT", "dependencies": { - "@ioredis/commands": "1.10.0", + "@ioredis/commands": "2.0.0", "cluster-key-slot": "1.1.1", "debug": "4.4.3", "denque": "2.1.0", "redis-errors": "1.2.0", - "redis-parser": "3.0.0", "standard-as-callback": "2.1.0" }, "engines": { - "node": ">=12.22.0" + "node": ">=20.0.0" }, "funding": { "type": "opencollective", @@ -7099,20 +7087,9 @@ "node_modules/redis-errors": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", - "integrity": "sha1-62LSrbFeTq9GEMBK/hUpOEJQq60=", + "integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==", "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/redis-parser": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz", - "integrity": "sha1-tm2CjNyv5rS4pCin3vTGvKwxyLQ=", - "dev": true, - "dependencies": { - "redis-errors": "^1.0.0" - }, + "license": "MIT", "engines": { "node": ">=4" } diff --git a/package.json b/package.json index 32f19348..a35ab55b 100644 --- a/package.json +++ b/package.json @@ -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", @@ -45,11 +45,11 @@ "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": { @@ -57,7 +57,6 @@ } }, "devDependencies": { - "@types/ioredis": "^4.28.0", "@types/jest": "^27.0.0", "@types/lodash": "^4.14.162", "@typescript-eslint/eslint-plugin": "^7.18.0", @@ -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", diff --git a/src/storages/inRedis/RedisAdapter.ts b/src/storages/inRedis/RedisAdapter.ts index c3d3ab8e..7fa48b63 100644 --- a/src/storages/inRedis/RedisAdapter.ts +++ b/src/storages/inRedis/RedisAdapter.ts @@ -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'; @@ -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 { @@ -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 diff --git a/src/storages/inRedis/__tests__/RedisAdapter.spec.ts b/src/storages/inRedis/__tests__/RedisAdapter.spec.ts index ec0742ba..40174e4b 100644 --- a/src/storages/inRedis/__tests__/RedisAdapter.spec.ts +++ b/src/storages/inRedis/__tests__/RedisAdapter.spec.ts @@ -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, @@ -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, @@ -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', () => { diff --git a/types/splitio.d.ts b/types/splitio.d.ts index 489a4bab..64bba008 100644 --- a/types/splitio.d.ts +++ b/types/splitio.d.ts @@ -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; @@ -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.