diff --git a/common/changes/@microsoft/rush/sennyeya-fix-redis-error_2025-08-26-23-37.json b/common/changes/@microsoft/rush/sennyeya-fix-redis-error_2025-08-26-23-37.json new file mode 100644 index 00000000000..16ad45039d3 --- /dev/null +++ b/common/changes/@microsoft/rush/sennyeya-fix-redis-error_2025-08-26-23-37.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "Treat intermittent ignored redis errors as warnings and allow build to continue.", + "type": "none", + "packageName": "@microsoft/rush" + } + ], + "packageName": "@microsoft/rush", + "email": "aramissennyeydd@users.noreply.github.com" +} \ No newline at end of file diff --git a/common/config/subspaces/default/pnpm-lock.yaml b/common/config/subspaces/default/pnpm-lock.yaml index b9ceb1be59b..85393b99174 100644 --- a/common/config/subspaces/default/pnpm-lock.yaml +++ b/common/config/subspaces/default/pnpm-lock.yaml @@ -4557,8 +4557,8 @@ importers: ../../../rush-plugins/rush-redis-cobuild-plugin: dependencies: '@redis/client': - specifier: ~1.5.5 - version: 1.5.14 + specifier: ~5.8.2 + version: 5.8.2 '@rushstack/node-core-library': specifier: workspace:* version: link:../../libraries/node-core-library @@ -11047,13 +11047,11 @@ packages: react: 17.0.2 dev: true - /@redis/client@1.5.14: - resolution: {integrity: sha512-YGn0GqsRBFUQxklhY7v562VMOP0DcmlrHHs3IV1mFE3cbxe31IITUkqhBcIhVSI/2JqtWAJXg5mjV4aU+zD0HA==} - engines: {node: '>=14'} + /@redis/client@5.8.2: + resolution: {integrity: sha512-WtMScno3+eBpTac1Uav2zugXEoXqaU23YznwvFgkPwBQVwEHTDgOG7uEAObtZ/Nyn8SmAMbqkEubJaMOvnqdsQ==} + engines: {node: '>= 18'} dependencies: cluster-key-slot: 1.1.2 - generic-pool: 3.9.0 - yallist: 4.0.0 dev: false /@reduxjs/toolkit@1.8.6(react-redux@8.0.7)(react@17.0.2): @@ -21070,11 +21068,6 @@ packages: loader-utils: 3.2.1 dev: false - /generic-pool@3.9.0: - resolution: {integrity: sha512-hymDOu5B53XvN4QT9dBmZxPX4CWhBPPLguTZ9MMFeFa/Kg0xWVfylOVNlJji/E7yTZWFd/q9GO5TxDLq156D7g==} - engines: {node: '>= 4'} - dev: false - /gensync@1.0.0-beta.2: resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} engines: {node: '>=6.9.0'} diff --git a/common/config/subspaces/default/repo-state.json b/common/config/subspaces/default/repo-state.json index eb22dd89def..9b98d794324 100644 --- a/common/config/subspaces/default/repo-state.json +++ b/common/config/subspaces/default/repo-state.json @@ -1,5 +1,5 @@ // DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush. { - "pnpmShrinkwrapHash": "c643d2cc7e2c60ef034a6557fc89760140d42f66", + "pnpmShrinkwrapHash": "e0b573b05fff66c7c9e7ae104e8a2f863ef58864", "preferredVersionsHash": "61cd419c533464b580f653eb5f5a7e27fe7055ca" } diff --git a/rush-plugins/rush-redis-cobuild-plugin/package.json b/rush-plugins/rush-redis-cobuild-plugin/package.json index 1d4ae446141..49102c4e98e 100644 --- a/rush-plugins/rush-redis-cobuild-plugin/package.json +++ b/rush-plugins/rush-redis-cobuild-plugin/package.json @@ -19,7 +19,7 @@ "_phase:test": "heft run --only test -- --clean" }, "dependencies": { - "@redis/client": "~1.5.5", + "@redis/client": "~5.8.2", "@rushstack/node-core-library": "workspace:*", "@rushstack/rush-sdk": "workspace:*" }, diff --git a/rush-plugins/rush-redis-cobuild-plugin/src/RedisCobuildLockProvider.ts b/rush-plugins/rush-redis-cobuild-plugin/src/RedisCobuildLockProvider.ts index effa7ec8cf2..3c2398baca8 100644 --- a/rush-plugins/rush-redis-cobuild-plugin/src/RedisCobuildLockProvider.ts +++ b/rush-plugins/rush-redis-cobuild-plugin/src/RedisCobuildLockProvider.ts @@ -46,10 +46,18 @@ export class RedisCobuildLockProvider implements ICobuildLockProvider { string >(); - private readonly _redisClient: RedisClientType; + private readonly _redisClient: RedisClientType; public constructor(options: IRedisCobuildLockProviderOptions, rushSession: RushSession) { this._options = RedisCobuildLockProvider.expandOptionsWithEnvironmentVariables(options); + // Provide a default reconnect strategy that prevents more than 5 reconnect attempts. + this._options.socket = { + reconnectStrategy: (count: number) => { + this._terminal.writeErrorLine(`Redis client reconnecting attempt #${count}`); + return count < 5 ? count * 1000 : false; + }, + ...this._options.socket + }; this._terminal = rushSession.getLogger('RedisCobuildLockProvider').terminal; try { this._redisClient = createClient(this._options); @@ -95,11 +103,20 @@ export class RedisCobuildLockProvider implements ICobuildLockProvider { } catch (e) { throw new Error(`Failed to connect to redis server: ${e.message}`); } + + // Register error event handler to avoid process exit when redis client error occurs. + this._redisClient.on('error', (e: Error) => { + if (e.message) { + this._terminal.writeErrorLine(`Redis client error: ${e.message}`); + } else { + this._terminal.writeErrorLine(`Redis client error: ${e}`); + } + }); } public async disconnectAsync(): Promise { try { - await this._redisClient.disconnect(); + await this._redisClient.destroy(); } catch (e) { throw new Error(`Failed to disconnect to redis server: ${e.message}`); } diff --git a/rush-plugins/rush-redis-cobuild-plugin/src/test/RedisCobuildLockProvider.test.ts b/rush-plugins/rush-redis-cobuild-plugin/src/test/RedisCobuildLockProvider.test.ts index 3fa6cf43c02..ede5f15c7f1 100644 --- a/rush-plugins/rush-redis-cobuild-plugin/src/test/RedisCobuildLockProvider.test.ts +++ b/rush-plugins/rush-redis-cobuild-plugin/src/test/RedisCobuildLockProvider.test.ts @@ -58,7 +58,12 @@ describe(RedisCobuildLockProvider.name, () => { get: jest.fn().mockImplementation((key: string) => { return storage[key]; }) - } as unknown as RedisClientType; + } as unknown as RedisClientType< + redisAPI.RedisModules, + redisAPI.RedisFunctions, + redisAPI.RedisScripts, + 2 | 3 + >; }); });