mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 09:20:15 +01:00
ci: Improve Redis client disconnection handling in integration tests
- Updated the afterAll cleanup logic in integration tests for GenerationJobManager, RedisEventTransport, and RedisJobStore to use `quit()` for graceful disconnection of the Redis client. - Added fallback to `disconnect()` if `quit()` fails, enhancing robustness in resource management during test teardown. - Improved comments for clarity on the disconnection process and error handling.
This commit is contained in:
parent
71a1a69568
commit
10e9e2c008
3 changed files with 27 additions and 9 deletions
|
|
@ -45,11 +45,17 @@ describe('GenerationJobManager Integration Tests', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
if (ioredisClient && 'disconnect' in ioredisClient) {
|
if (ioredisClient) {
|
||||||
try {
|
try {
|
||||||
ioredisClient.disconnect();
|
// Use quit() to gracefully close - waits for pending commands
|
||||||
|
await ioredisClient.quit();
|
||||||
} catch {
|
} catch {
|
||||||
// Ignore disconnect errors
|
// Fall back to disconnect if quit fails
|
||||||
|
try {
|
||||||
|
ioredisClient.disconnect();
|
||||||
|
} catch {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
process.env = originalEnv;
|
process.env = originalEnv;
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,17 @@ describe('RedisEventTransport Integration Tests', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
if (ioredisClient && 'disconnect' in ioredisClient) {
|
if (ioredisClient) {
|
||||||
try {
|
try {
|
||||||
ioredisClient.disconnect();
|
// Use quit() to gracefully close - waits for pending commands
|
||||||
|
await ioredisClient.quit();
|
||||||
} catch {
|
} catch {
|
||||||
// Ignore
|
// Fall back to disconnect if quit fails
|
||||||
|
try {
|
||||||
|
ioredisClient.disconnect();
|
||||||
|
} catch {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
process.env = originalEnv;
|
process.env = originalEnv;
|
||||||
|
|
|
||||||
|
|
@ -57,11 +57,17 @@ describe('RedisJobStore Integration Tests', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
if (ioredisClient && 'disconnect' in ioredisClient) {
|
if (ioredisClient) {
|
||||||
try {
|
try {
|
||||||
ioredisClient.disconnect();
|
// Use quit() to gracefully close - waits for pending commands
|
||||||
|
await ioredisClient.quit();
|
||||||
} catch {
|
} catch {
|
||||||
// Ignore disconnect errors
|
// Fall back to disconnect if quit fails
|
||||||
|
try {
|
||||||
|
ioredisClient.disconnect();
|
||||||
|
} catch {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
process.env = originalEnv;
|
process.env = originalEnv;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue