MCPcopy Index your code
hub / github.com/redis/node-redis / #returnClient

Method #returnClient

packages/client/lib/client/pool.ts:509–528  ·  view source on GitHub ↗
(node: DoublyLinkedNode<RedisClientType<M, F, S, RESP, TYPE_MAPPING>>)

Source from the content-addressed store, hash-verified

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

Callers 2

#executeTaskMethod · 0.95
#createMethod · 0.80

Calls 6

#executeTaskMethod · 0.95
#scheduleCleanupMethod · 0.95
publishFunction · 0.90
shiftMethod · 0.45
removeMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected