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

Prevent endless loop detection #76

Closed
mrpmorris opened this issue Aug 16, 2020 · 0 comments · Fixed by #77
Closed

Prevent endless loop detection #76

mrpmorris opened this issue Aug 16, 2020 · 0 comments · Fixed by #77

Comments

@mrpmorris
Copy link
Owner

Problem

At the moment Fluxor detects self-inflicted endless loop and breaks out of the cycle. This loop started to happen once Effects were executed within a task (so that exceptions could be caught without holding up the pipeline).

In previous versions the routing middleware was able to check the browser's current URL against state and only dispatch an action if it is different, and this was sufficient because although effects can be async, the routing middleware's effect didn't await so executed synchronously.

Now that effects are all run inside an awaited task, this cannot happen synchronously, so by the time the middle checks the state against the current URL the URL could have changed due to an auth redirect to a sign-in page. At which point the middleware updates the browser URL, taking us back to the app, at which point the auth redirects us back to the sign-in page, ad ininitum.

Solution

Change the effects dispatcher so it executes each task outside of the Task.Run (capturing any exceptions to a list), and then only run the Task.WhenAll inside the Task.Run. This will give synchronous effects the opportunity to run and complete immediately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant