Skip to content

Commit

Permalink
Fix memory leak in unsubscribe while disconnected (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored Jun 26, 2020
1 parent 347ff4b commit e48d529
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,11 @@ export class Connection {
subscribe: () => this.subscribeMessage(callback, subscribeMessage),
unsubscribe: async () => {
// No need to unsubscribe if we're disconnected
if (!this.connected) {
return;
if (this.connected) {
await this.sendMessagePromise(
messages.unsubscribeEvents(commandId)
);
}
await this.sendMessagePromise(messages.unsubscribeEvents(commandId));
this.commands.delete(commandId);
},
};
Expand Down

0 comments on commit e48d529

Please sign in to comment.