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(debounceTime): unschedule dangling task on unsubscribe before complete #6464

Merged

Conversation

backbone87
Copy link
Contributor

@backbone87 backbone87 commented Jun 9, 2021

Description:

Since debounceTime is not based on debounce anymore (#6049), the "notifier subscription" is not managed within the parent subscription anymore, but scheduled "raw". We need to make sure we dont leave dangling tasks behind.

I am not sure how to test this.

edit: this also prevents stopped notifications, if the source errors, because that could also leave dangling tasks behind

@cartant
Copy link
Collaborator

cartant commented Jun 9, 2021

I think it would be 'more correct' to add the scheduled action - activeTask - to subscriber. As to how this should be tested I'll have a think about it.

@backbone87 backbone87 force-pushed the fix/debounce-time-dangling-task branch from e058bdf to 4c7deff Compare June 10, 2021 03:30
@backbone87
Copy link
Contributor Author

didnt notice that this was possible, i pushed a version, where the activeTask subscription is managed within the outer subscriber

@cartant
Copy link
Collaborator

cartant commented Jun 11, 2021

It ought to be possible to test this using the asyncScheduler's actions property, as is done here (with the animationFrameScheduler):

expect(animationFrame.actions.length).to.equal(2);
action1.unsubscribe();
action2.unsubscribe();
expect(animationFrame.actions.length).to.equal(0);

@benlesh benlesh added the 7.x Issues and PRs for version 6.x label Jun 21, 2021
Copy link
Collaborator

@cartant cartant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is fine, but this needs a test that's fixed by the change.

@backbone87 backbone87 force-pushed the fix/debounce-time-dangling-task branch from 4c7deff to 6103acb Compare July 2, 2021 19:47
@backbone87
Copy link
Contributor Author

test added (and verified that it is failing without the fix)

Copy link
Collaborator

@cartant cartant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

@benlesh benlesh merged commit 7ab0a4c into ReactiveX:master Jul 5, 2021
@benlesh
Copy link
Member

benlesh commented Jul 5, 2021

Thank you, @backbone87

@backbone87 backbone87 deleted the fix/debounce-time-dangling-task branch July 11, 2021 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
7.x Issues and PRs for version 6.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants