(node: DoublyLinkedNode<RedisClientType<M, F, S, RESP, TYPE_MAPPING>>)
| 507 | } |
| 508 | |
| 509 | #returnClient(node: DoublyLinkedNode<RedisClientType<M, F, S, RESP, TYPE_MAPPING>>) { |
| 510 | const task = this.#tasksQueue.shift(); |
| 511 | if (task) { |
| 512 | clearTimeout(task.timeout); |
| 513 | publish(CHANNELS.POOL_CONNECTION_WAIT, () => ({ clientId: node.value._clientId, waitStartTimestamp: task.waitStartTimestamp })); |
| 514 | this.#executeTask(node, task.resolve, task.reject, task.fn); |
| 515 | return; |
| 516 | } |
| 517 | |
| 518 | this.#clientsInUse.remove(node); |
| 519 | this.#idleClients.push(node.value); |
| 520 | |
| 521 | // If closing and all tasks are done, signal the drain is complete |
| 522 | if (this.#isClosing && this.#clientsInUse.length === 0) { |
| 523 | this.#drainResolve?.(); |
| 524 | return; |
| 525 | } |
| 526 | |
| 527 | this.#scheduleCleanup(); |
| 528 | } |
| 529 | |
| 530 | cleanupTimeout?: NodeJS.Timeout; |
| 531 |
no test coverage detected