Skip to content

Commit e2733cf

Browse files
committed
Make it possible to wait until all redis instances finish the quit routine
1 parent 3977a97 commit e2733cf

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/redis-pubsub.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,11 @@ export class RedisPubSub implements PubSubEngine {
133133
return this.redisPublisher;
134134
}
135135

136-
public close(): void {
137-
this.redisPublisher.quit();
138-
this.redisSubscriber.quit();
136+
public close(): Promise<any> {
137+
return Promise.all([
138+
this.redisPublisher.quit(),
139+
this.redisSubscriber.quit(),
140+
]);
139141
}
140142

141143
private onMessage(pattern: string, channel: string, message: string) {

src/test/tests.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@ describe('RedisPubSub', () => {
5353

5454
it('should verify close calls pub and sub quit methods', done => {
5555
const pubSub = new RedisPubSub(mockOptions);
56-
pubSub.close();
57-
expect(quitSpy.callCount).to.equal(2);
58-
done();
56+
57+
pubSub.close()
58+
.then(() => {
59+
expect(quitSpy.callCount).to.equal(2);
60+
done();
61+
})
62+
.catch(done);
5963
});
6064

6165
it('can subscribe to specific redis channel and called when a message is published on it', done => {

0 commit comments

Comments
 (0)