-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Dispatching events within a guard leads to loop in router-store #201
Comments
Same is happening for me. An action with type: ROUTER_CANCEL is being dispatched, then the infinite loop begins. |
I had some problems with it. I resolved as I wrote it in the Issue #68. However it should be nice to know which guard caused the cancellation to handle the redirecting properly. |
@csutorasr this issue has nothing to do with guards cancelling anything as the guard just returns true. |
Anyone have a workaround for this issue? |
I kicked out Both are not very solid solutions... |
+1 |
There is another effect that is caused by the same mechanism: |
A workaround for this issue is to change the name of the router slice to something other than |
Fixed via #355 |
I'm submitting a...
What is the current behavior?
Dispatching an action synchronously in a guard leads to a loop.
Expected behavior:
No loop.
Minimal reproduction of the problem with instructions:
https://plnkr.co/edit/MNtybtGWdLg2e2dQu3EJ?p=preview
Watch the Console, while you click the link. NOTE: this causes a loop and will lag out your browser!
Analysis
Dispatching the action will lead to this part of the router store that will check if a navigation is necessary. However,
this.router.url
will point to the old route, whilethis.storeState['routerReducer'].state.url
will point to the new route. Therefore, routing is cancelled and the same route is activated again, the guard is triggered again and then you have a loop.Version of affected browser(s),operating system(s), npm, node and ngrx:
NPM 5.3
Browser: all
OS: all
node 6 LTS
ngrx 4.0.x
The text was updated successfully, but these errors were encountered: