Skip to content

Commit e3ebda1

Browse files
committed
clean code
1 parent ae264ff commit e3ebda1

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/client/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,8 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
216216

217217
if (promises.length) {
218218
this.#tick();
219+
await Promise.all(promises);
219220
}
220-
221-
await Promise.all(promises);
222221
};
223222

224223
return new RedisSocket(socketInitiator, this.#options?.socket)
@@ -318,9 +317,9 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
318317
}
319318

320319
// using `#sendCommand` cause `sendCommand` is overwritten in legacy mode
321-
async #sendCommand<T = RedisCommandRawReply>(args: RedisCommandArguments, options?: ClientCommandOptions, bufferMode?: boolean): Promise<T> {
320+
#sendCommand<T = RedisCommandRawReply>(args: RedisCommandArguments, options?: ClientCommandOptions, bufferMode?: boolean): Promise<T> {
322321
if (!this.#socket.isOpen) {
323-
throw new ClientClosedError();
322+
return Promise.reject(new ClientClosedError());
324323
}
325324

326325
if (options?.isolated) {
@@ -334,7 +333,7 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
334333

335334
const promise = this.#queue.addCommand<T>(args, options, bufferMode);
336335
this.#tick();
337-
return await promise;
336+
return promise;
338337
}
339338

340339
async scriptsExecutor(script: RedisScript, args: Array<unknown>): Promise<RedisCommandReply<typeof script>> {

0 commit comments

Comments
 (0)