Skip to content

Commit fad2397

Browse files
authored
fix #2333 - fix quit reply (#2346)
1 parent 2042a67 commit fad2397

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

packages/client/lib/client/index.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,13 +841,14 @@ describe('Client', () => {
841841
quitPromise = client.quit();
842842
assert.equal(client.isOpen, false);
843843

844-
const [ping] = await Promise.all([
844+
const [ping, quit] = await Promise.all([
845845
pingPromise,
846-
assert.doesNotReject(quitPromise),
846+
quitPromise,
847847
assert.rejects(client.ping(), ClientClosedError)
848848
]);
849849

850850
assert.equal(ping, 'PONG');
851+
assert.equal(quit, 'OK');
851852
}, {
852853
...GLOBAL.SERVERS.OPEN,
853854
disableClientSetup: true

packages/client/lib/client/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -586,16 +586,17 @@ export default class RedisClient<
586586

587587
pUnsubscribe = this.PUNSUBSCRIBE;
588588

589-
QUIT(): Promise<void> {
590-
return this.#socket.quit(() => {
591-
const quitPromise = this.#queue.addCommand(['QUIT'], {
589+
QUIT(): Promise<string> {
590+
return this.#socket.quit(async () => {
591+
const quitPromise = this.#queue.addCommand<string>(['QUIT'], {
592592
ignorePubSubMode: true
593593
});
594594
this.#tick();
595-
return Promise.all([
595+
const [reply] = await Promise.all([
596596
quitPromise,
597597
this.#destroyIsolationPool()
598598
]);
599+
return reply;
599600
});
600601
}
601602

packages/client/lib/client/socket.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,15 @@ export default class RedisSocket extends EventEmitter {
240240
this.emit('end');
241241
}
242242

243-
async quit(fn: () => Promise<unknown>): Promise<void> {
243+
async quit<T>(fn: () => Promise<T>): Promise<T> {
244244
if (!this.#isOpen) {
245245
throw new ClientClosedError();
246246
}
247247

248248
this.#isOpen = false;
249-
await fn();
249+
const reply = await fn();
250250
this.#disconnect();
251+
return reply;
251252
}
252253

253254
#isCorked = false;

0 commit comments

Comments
 (0)