Skip to content

Commit e48d529

Browse files
authored
Fix memory leak in unsubscribe while disconnected (#127)
1 parent 347ff4b commit e48d529

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/connection.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,11 @@ export class Connection {
297297
subscribe: () => this.subscribeMessage(callback, subscribeMessage),
298298
unsubscribe: async () => {
299299
// No need to unsubscribe if we're disconnected
300-
if (!this.connected) {
301-
return;
300+
if (this.connected) {
301+
await this.sendMessagePromise(
302+
messages.unsubscribeEvents(commandId)
303+
);
302304
}
303-
await this.sendMessagePromise(messages.unsubscribeEvents(commandId));
304305
this.commands.delete(commandId);
305306
},
306307
};

0 commit comments

Comments
 (0)