fix(Subscription): null _parentage on unsubscribe #6352
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This PR fixed the bug reported in #6351 by nulling
this._parentage
before the array is iterated. This was an oversight. It should have been nulled as isthis._teardowns
, immediately after it is destructured:rxjs/src/internal/Subscription.ts
Lines 76 to 78 in 7b30546
If
this._parentage
is not nulled, it's mutated as it's iterated and parents can be left holding onto child subscriptions that have been closed.The PR also adds - in a separate commit - an
if
statement around the handling of_parentage
, so that the implementation is more like what's done with_teardowns
. If there's some reason for not using theif
statement, we can just revert that commit.Related issue (if exists): #6351