Skip to content

Commit

Permalink
Mitigate event emitter "memory leak" warnings when a significant numb…
Browse files Browse the repository at this point in the history
…er of HomeKit camera streaming events occur simultaneously.
  • Loading branch information
hjdhjd committed Jun 16, 2024
1 parent 4a8fbca commit 97976b8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib/camera/RTPStreamManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ export class RTPStreamManagement {

if (this.activeConnection) {
this.activeConnection.removeListener(HAPConnectionEvent.CLOSED, this.activeConnectionClosedListener);
this.activeConnection.setMaxListeners(this.activeConnection.getMaxListeners() - 1);
this.activeConnection = undefined;
}

Expand Down Expand Up @@ -1098,6 +1099,7 @@ export class RTPStreamManagement {
"Found non-nil `activeConnection` when trying to setup streaming endpoints, even though streamStatus is reported to be AVAILABLE!");

this.activeConnection = connection;
this.activeConnection.setMaxListeners(this.activeConnection.getMaxListeners() + 1);
this.activeConnection.on(HAPConnectionEvent.CLOSED, this.activeConnectionClosedListener);

// noinspection JSDeprecatedSymbols
Expand Down

0 comments on commit 97976b8

Please sign in to comment.