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
@@ -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"
}
17 changes: 5 additions & 12 deletions common/config/subspaces/default/pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion common/config/subspaces/default/repo-state.json
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 1 addition & 1 deletion rush-plugins/rush-redis-cobuild-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,18 @@ export class RedisCobuildLockProvider implements ICobuildLockProvider {
string
>();

private readonly _redisClient: RedisClientType<RedisModules, RedisFunctions, RedisScripts>;
private readonly _redisClient: RedisClientType<RedisModules, RedisFunctions, RedisScripts, 2 | 3>;

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);
Expand Down Expand Up @@ -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<void> {
try {
await this._redisClient.disconnect();
await this._redisClient.destroy();
} catch (e) {
throw new Error(`Failed to disconnect to redis server: ${e.message}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
>;
});
});

Expand Down