How to detect subscription leakage by tracking their total number? #7332
Unanswered
ArtemAvramenko
asked this question in
Q&A
Replies: 1 comment
-
This is the solution I've come up with so far: import { Subscriber } from 'rxjs';
Object.defineProperty(Subscriber.prototype, 'closed', {
get: function (this: { __closed: boolean; }) { return this.__closed; },
set: function (this: { __closed: boolean; }, value: boolean) {
this.__closed = value;
totalSubscriptionCounter += value ? -1 : 1;
}
}); If anyone knows any other scenarios of subscription leaks, please tell me. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Meaning not an individual Observable, but all subscriptions in all currently existing Observables.
This is necessary so that testers can detect bugs with a constantly growing number of subscriptions.
It is important to catch the very fact of subscription leakage, further detailed research will be done by developers.
Now such bugs are detected very slowly by indirect signs, such as obvious memory leaks. I would like testers to be able to see the number of active subscriptions as an indicator of the application's health.
Beta Was this translation helpful? Give feedback.
All reactions