Skip to content

Commit

Permalink
fix: make sure closing is returned in every close call
Browse files Browse the repository at this point in the history
  • Loading branch information
manast committed Apr 10, 2020
1 parent 011b8ac commit 88c5948
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/classes/queue-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ export class QueueBase extends EventEmitter {
}

close() {
return (this.closing = this.connection.close());
if (!this.closing) {
this.closing = this.connection.close();
}
return this.closing;
}

disconnect() {
Expand Down
5 changes: 4 additions & 1 deletion src/classes/queue-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export class QueueEvents extends QueueBase {
}

async close() {
return (this.closing = this.disconnect());
if (!this.closing) {
this.closing = this.disconnect();
}
return this.closing;
}
}
5 changes: 4 additions & 1 deletion src/classes/queue-scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,13 @@ export class QueueScheduler extends QueueBase {
}

async close() {
if (this.closing) {
return this.closing;
}
if (this.isBlocked) {
this.closing = this.disconnect();
} else {
super.close();
this.closing = super.close();
}
return this.closing;
}
Expand Down

0 comments on commit 88c5948

Please sign in to comment.