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

Infinite loop in closed async actions #7148

Open
43081j opened this issue Jan 13, 2023 · 0 comments
Open

Infinite loop in closed async actions #7148

43081j opened this issue Jan 13, 2023 · 0 comments

Comments

@43081j
Copy link
Contributor

43081j commented Jan 13, 2023

Describe the bug

AsyncAction uses setInterval for delays, likely due to the fact setTimeout is often throttled/less accurate.

So the flow seems to roughly be this:

  • schedule(state, delay)
  • setInterval is now created to fire in delay time
  • delay time passes
  • execute is called
  • clearInterval is called (via the recycle method)

If the action is closed when we call schedule, nothing will happen as you can see here:

if (this.closed) {
return this;
}

However, if the action is closed while we're waiting for delay time to pass, we will hit this:

if (this.closed) {
return new Error('executing a cancelled action');
}

This means we throw and never clear the interval.

The interval then continues to fire forever (since it is an interval after all, being used as if it were a timeout), throwing the same Error infinitely.

This shouldn't be possible anyway because closing the subscription should be done via unsubscribe, which will clear the interval. There's probably a separate bug or a problem on my end that results in this weird state happening. However, its probably still sensible to cover the inf loop purely from a logic point of view even if you think it shouldn't ever be hit.

Expected behavior

A few less infinite loops

Reproduction code

No response

Reproduction URL

No response

Version

latest (exists in 7 & 8)

Environment

No response

Additional context

No response

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

No branches or pull requests

1 participant