You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
@@ -841,13 +841,14 @@ describe('Client', () => {
|
|||||||
quitPromise = client.quit();
|
quitPromise = client.quit();
|
||||||
assert.equal(client.isOpen, false);
|
assert.equal(client.isOpen, false);
|
||||||
|
|
||||||
const [ping] = await Promise.all([
|
const [ping, quit] = await Promise.all([
|
||||||
pingPromise,
|
pingPromise,
|
||||||
assert.doesNotReject(quitPromise),
|
quitPromise,
|
||||||
assert.rejects(client.ping(), ClientClosedError)
|
assert.rejects(client.ping(), ClientClosedError)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert.equal(ping, 'PONG');
|
assert.equal(ping, 'PONG');
|
||||||
|
assert.equal(quit, 'OK');
|
||||||
}, {
|
}, {
|
||||||
...GLOBAL.SERVERS.OPEN,
|
...GLOBAL.SERVERS.OPEN,
|
||||||
disableClientSetup: true
|
disableClientSetup: true
|
||||||
|
@@ -586,16 +586,17 @@ export default class RedisClient<
|
|||||||
|
|
||||||
pUnsubscribe = this.PUNSUBSCRIBE;
|
pUnsubscribe = this.PUNSUBSCRIBE;
|
||||||
|
|
||||||
QUIT(): Promise<void> {
|
QUIT(): Promise<string> {
|
||||||
return this.#socket.quit(() => {
|
return this.#socket.quit(async () => {
|
||||||
const quitPromise = this.#queue.addCommand(['QUIT'], {
|
const quitPromise = this.#queue.addCommand<string>(['QUIT'], {
|
||||||
ignorePubSubMode: true
|
ignorePubSubMode: true
|
||||||
});
|
});
|
||||||
this.#tick();
|
this.#tick();
|
||||||
return Promise.all([
|
const [reply] = await Promise.all([
|
||||||
quitPromise,
|
quitPromise,
|
||||||
this.#destroyIsolationPool()
|
this.#destroyIsolationPool()
|
||||||
]);
|
]);
|
||||||
|
return reply;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -240,14 +240,15 @@ export default class RedisSocket extends EventEmitter {
|
|||||||
this.emit('end');
|
this.emit('end');
|
||||||
}
|
}
|
||||||
|
|
||||||
async quit(fn: () => Promise<unknown>): Promise<void> {
|
async quit<T>(fn: () => Promise<T>): Promise<T> {
|
||||||
if (!this.#isOpen) {
|
if (!this.#isOpen) {
|
||||||
throw new ClientClosedError();
|
throw new ClientClosedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#isOpen = false;
|
this.#isOpen = false;
|
||||||
await fn();
|
const reply = await fn();
|
||||||
this.#disconnect();
|
this.#disconnect();
|
||||||
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
#isCorked = false;
|
#isCorked = false;
|
||||||
|
Reference in New Issue
Block a user