From 156588b946724e37bfc895b60c002831e00f1ec0 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Thu, 26 Jun 2025 15:04:44 -0700 Subject: [PATCH] test(redis-4): fix tests with redis@4.4.0 and earlier In redis@4.4.0 and earlier versions of redis v4, client.disconnect() will throw if the connect failed. That broke the "with empty string for client URL, ..." test case, at least on macOS: npm run test:docker:run RUN_REDIS_TESTS=1 npm t I cannot explain why this is not failing in CI. Perhaps something platform specific? This is related to socket handling in the redis client. I believe the relevant change in node-redis was: https://github.com/redis/node-redis/pull/2295 which was part of `@redis/client@1.3.1` which was included in `redis@4.4.0`. --- .../test/redis.test.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/node/opentelemetry-instrumentation-redis-4/test/redis.test.ts b/plugins/node/opentelemetry-instrumentation-redis-4/test/redis.test.ts index 14b439e797..d6d86d93c8 100644 --- a/plugins/node/opentelemetry-instrumentation-redis-4/test/redis.test.ts +++ b/plugins/node/opentelemetry-instrumentation-redis-4/test/redis.test.ts @@ -314,7 +314,12 @@ describe('redis@^4.0.0', () => { // Ignore. If the test Redis is not at the default port we expect this // to error. } - await newClient.disconnect(); + try { + await newClient.disconnect(); + } catch (_disconnectErr) { + // Ignore. In redis@4.4.0 and earlier this disconnect throws + // "The client is closed" if the connect failed. + } const [span] = getTestSpans(); assert.strictEqual(span.name, 'redis-connect');