diff --git a/common/changes/@microsoft/rush/fix-redis-reconnect_2026-05-07-00-00.json b/common/changes/@microsoft/rush/fix-redis-reconnect_2026-05-07-00-00.json new file mode 100644 index 00000000000..43844f89bcf --- /dev/null +++ b/common/changes/@microsoft/rush/fix-redis-reconnect_2026-05-07-00-00.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "Set Redis `connectTimeout` and `socketTimeout` so half-dead TCP connections (NAT/firewall) surface in seconds instead of stalling in-flight commands for many minutes while the kernel waits to give up.", + "type": "patch" + } + ], + "packageName": "@microsoft/rush" +} diff --git a/rush-plugins/rush-redis-cobuild-plugin/src/RedisCobuildLockProvider.ts b/rush-plugins/rush-redis-cobuild-plugin/src/RedisCobuildLockProvider.ts index 3c2398baca8..defc6908b35 100644 --- a/rush-plugins/rush-redis-cobuild-plugin/src/RedisCobuildLockProvider.ts +++ b/rush-plugins/rush-redis-cobuild-plugin/src/RedisCobuildLockProvider.ts @@ -50,8 +50,12 @@ export class RedisCobuildLockProvider implements ICobuildLockProvider { public constructor(options: IRedisCobuildLockProviderOptions, rushSession: RushSession) { this._options = RedisCobuildLockProvider.expandOptionsWithEnvironmentVariables(options); - // Provide a default reconnect strategy that prevents more than 5 reconnect attempts. + // Detect half-dead connections quickly. Without `socketTimeout`, a silently-dropped + // TCP connection (NAT/firewall) can stall in-flight commands for many minutes while + // the kernel waits to surface the failure. this._options.socket = { + connectTimeout: 10_000, + socketTimeout: 30_000, reconnectStrategy: (count: number) => { this._terminal.writeErrorLine(`Redis client reconnecting attempt #${count}`); return count < 5 ? count * 1000 : false;