Skip to content

Commit

Permalink
Fix throttle not clearing its internal interval when unsubscribed
Browse files Browse the repository at this point in the history
When a throttled stream is unsubscribed, its internal throttle interval
is not cleared, and the reference to its ID is removed, meaning it's
also not cleared at the end of the timeout.

This is essentially a memory leak, where the interval will live on in
the event loop forever without being cleared.

This commit adds a call to ThrottleOperator#clearInterval() in its _stop
method, clearing the interval and freeing it from the event loop.
  • Loading branch information
Avaq committed Jul 14, 2022
1 parent fee5f0d commit 4126438
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/extra/throttle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ThrottleOperator<T> implements Operator<T, T> {
_stop(): void {
this.ins._remove(this);
this.out = null as any;
this.id = null;
this.clearInterval();
}

clearInterval() {
Expand Down

0 comments on commit 4126438

Please sign in to comment.