Skip to content

Commit 296ddd5

Browse files
Merge pull request #15020 from yatin166/fix/close-redis-connection-properly
fix(microservices): ensure all redis connections are closed
2 parents 4c1184b + 4ff638b commit 296ddd5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

packages/microservices/server/server-redis.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ export class ServerRedis extends Server<RedisEvents, RedisStatus> {
104104
});
105105
}
106106

107-
public close() {
107+
public async close() {
108108
this.isManuallyClosed = true;
109-
this.pubClient && this.pubClient.quit();
110-
this.subClient && this.subClient.quit();
109+
this.pubClient && (await this.pubClient.quit());
110+
this.subClient && (await this.subClient.quit());
111111
this.pendingEventListeners = [];
112112
}
113113

packages/microservices/test/server/server-redis.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ describe('ServerRedis', () => {
5959
untypedServer.pubClient = pub;
6060
untypedServer.subClient = sub;
6161
});
62-
it('should close pub & sub server', () => {
63-
server.close();
62+
it('should close pub & sub server', async () => {
63+
await server.close();
6464

65-
expect(pub.quit.called).to.be.true;
66-
expect(sub.quit.called).to.be.true;
65+
expect(pub.quit.calledOnce).to.be.true;
66+
expect(sub.quit.calledOnce).to.be.true;
6767
});
6868
});
6969
describe('handleConnection', () => {

0 commit comments

Comments
 (0)