diff --git a/lib/client/index.ts b/lib/client/index.ts index 8850574e71..7026142c2f 100644 --- a/lib/client/index.ts +++ b/lib/client/index.ts @@ -216,9 +216,8 @@ export default class RedisClient if (promises.length) { this.#tick(); + await Promise.all(promises); } - - await Promise.all(promises); }; return new RedisSocket(socketInitiator, this.#options?.socket) @@ -318,9 +317,9 @@ export default class RedisClient } // using `#sendCommand` cause `sendCommand` is overwritten in legacy mode - async #sendCommand(args: RedisCommandArguments, options?: ClientCommandOptions, bufferMode?: boolean): Promise { + #sendCommand(args: RedisCommandArguments, options?: ClientCommandOptions, bufferMode?: boolean): Promise { if (!this.#socket.isOpen) { - throw new ClientClosedError(); + return Promise.reject(new ClientClosedError()); } if (options?.isolated) { @@ -334,7 +333,7 @@ export default class RedisClient const promise = this.#queue.addCommand(args, options, bufferMode); this.#tick(); - return await promise; + return promise; } async scriptsExecutor(script: RedisScript, args: Array): Promise> {