diff --git a/packages/api/src/stream/__tests__/GenerationJobManager.stream_integration.spec.ts b/packages/api/src/stream/__tests__/GenerationJobManager.stream_integration.spec.ts index cd7a5d4864..c593d3d15a 100644 --- a/packages/api/src/stream/__tests__/GenerationJobManager.stream_integration.spec.ts +++ b/packages/api/src/stream/__tests__/GenerationJobManager.stream_integration.spec.ts @@ -45,11 +45,17 @@ describe('GenerationJobManager Integration Tests', () => { }); afterAll(async () => { - if (ioredisClient && 'disconnect' in ioredisClient) { + if (ioredisClient) { try { - ioredisClient.disconnect(); + // Use quit() to gracefully close - waits for pending commands + await ioredisClient.quit(); } catch { - // Ignore disconnect errors + // Fall back to disconnect if quit fails + try { + ioredisClient.disconnect(); + } catch { + // Ignore + } } } process.env = originalEnv; diff --git a/packages/api/src/stream/__tests__/RedisEventTransport.stream_integration.spec.ts b/packages/api/src/stream/__tests__/RedisEventTransport.stream_integration.spec.ts index ad42573a5d..b70e53012e 100644 --- a/packages/api/src/stream/__tests__/RedisEventTransport.stream_integration.spec.ts +++ b/packages/api/src/stream/__tests__/RedisEventTransport.stream_integration.spec.ts @@ -29,11 +29,17 @@ describe('RedisEventTransport Integration Tests', () => { }); afterAll(async () => { - if (ioredisClient && 'disconnect' in ioredisClient) { + if (ioredisClient) { try { - ioredisClient.disconnect(); + // Use quit() to gracefully close - waits for pending commands + await ioredisClient.quit(); } catch { - // Ignore + // Fall back to disconnect if quit fails + try { + ioredisClient.disconnect(); + } catch { + // Ignore + } } } process.env = originalEnv; diff --git a/packages/api/src/stream/__tests__/RedisJobStore.stream_integration.spec.ts b/packages/api/src/stream/__tests__/RedisJobStore.stream_integration.spec.ts index d57fd1e08d..95ea15dbb3 100644 --- a/packages/api/src/stream/__tests__/RedisJobStore.stream_integration.spec.ts +++ b/packages/api/src/stream/__tests__/RedisJobStore.stream_integration.spec.ts @@ -57,11 +57,17 @@ describe('RedisJobStore Integration Tests', () => { }); afterAll(async () => { - if (ioredisClient && 'disconnect' in ioredisClient) { + if (ioredisClient) { try { - ioredisClient.disconnect(); + // Use quit() to gracefully close - waits for pending commands + await ioredisClient.quit(); } catch { - // Ignore disconnect errors + // Fall back to disconnect if quit fails + try { + ioredisClient.disconnect(); + } catch { + // Ignore + } } } process.env = originalEnv;