From 1f725826c7e01048b93af5301c81a914f290bd34 Mon Sep 17 00:00:00 2001 From: piyush0049 Date: Wed, 29 Jul 2026 16:21:15 +0530 Subject: [PATCH] fix(client): include acquire timeout duration in pool timeout error message --- packages/client/lib/client/pool.spec.ts | 25 +++++++++++++++++++++++++ packages/client/lib/client/pool.ts | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/packages/client/lib/client/pool.spec.ts b/packages/client/lib/client/pool.spec.ts index fa19504785d..bb13d886487 100644 --- a/packages/client/lib/client/pool.spec.ts +++ b/packages/client/lib/client/pool.spec.ts @@ -2,6 +2,7 @@ import { strict as assert } from 'node:assert'; import testUtils, { GLOBAL } from '../test-utils'; import { RESP_TYPES } from '../RESP/decoder'; import { RedisClientPool } from './pool'; +import { TimeoutError } from '../errors'; describe('RedisClientPool', () => { it('chained withCommandOptions(...).withTypeMapping(...) preserves earlier overrides at dispatch', () => { @@ -295,4 +296,28 @@ describe('RedisClientPool', () => { }, GLOBAL.SERVERS.OPEN ); + + testUtils.testWithClientPool( + 'rejects with TimeoutError when acquireTimeout expires', + async (pool) => { + const longRunningTask = pool.execute(async () => { + await new Promise((resolve) => setTimeout(resolve, 200)); + }); + + await assert.rejects( + pool.execute(async () => {}), + (err: unknown) => { + assert(err instanceof TimeoutError); + assert.equal(err.message, 'Timeout waiting for a client after 50ms'); + return true; + } + ); + + await longRunningTask; + }, + { + ...GLOBAL.SERVERS.OPEN, + poolOptions: { minimum: 1, maximum: 1, acquireTimeout: 50 }, + } + ); }); diff --git a/packages/client/lib/client/pool.ts b/packages/client/lib/client/pool.ts index 34942bcca4a..0736a94aaad 100644 --- a/packages/client/lib/client/pool.ts +++ b/packages/client/lib/client/pool.ts @@ -458,7 +458,7 @@ export class RedisClientPool< timeout = setTimeout( () => { this._self.#tasksQueue.remove(task, tail); - reject(new TimeoutError('Timeout waiting for a client')); // TODO: message + reject(new TimeoutError(`Timeout waiting for a client after ${this._self.#options.acquireTimeout}ms`)); }, this._self.#options.acquireTimeout );