Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix throttle not clearing its internal interval when unsubscribed #337

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Avaq
Copy link

@Avaq Avaq commented Jul 14, 2022

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 PR adds a call to ThrottleOperator#clearInterval() in its _stop method, clearing the interval and freeing it from the event loop.


I checked if the same problem exists for debounce, but it looks like it was already fixed in #296:

_stop(): void {
this.ins._remove(this);
this.out = null as any;
this.clearInterval();
}

@Avaq Avaq changed the title Fix throttle not clearing its internal interval when unsubscribed Fix throttle not clearing its internal interval interval when unsubscribed Jul 14, 2022
@Avaq Avaq changed the title Fix throttle not clearing its internal interval interval when unsubscribed Fix throttle not clearing its internal interval when unsubscribed Jul 14, 2022
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant