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

@ngrx/router-store triggers unexpected ROUTER_CANCEL action if store is modified by guard . #446

Closed
majo44 opened this issue Oct 3, 2017 · 7 comments

Comments

@majo44
Copy link

majo44 commented Oct 3, 2017

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request

What is the current behavior?

If the store is asynchronously modified by route guard, during the transition StoreRouterConnectingModule is executing navigateByUrl on router, because the url set in state by StoreRouterConnectingModule (taken from NavigationStart event) is different than router.url value (which contains url from before of transition). This cause cancellation of previous navigation, and next try to execute the navigation (for same url), and again and again, until the guard will not return true synchronously.

Please look at code https://github.com/ngrx/platform/blob/master/modules/router-store/src/router_store_module.ts#L209

Expected behavior:

StoreRouterConnectingModule should not trigger navigateByUrl if state is modified by guard.

Minimal reproduction of the problem with instructions:

Please look at: http://plnkr.co/edit/SbecXWSzFMnSRA9JFQ0i

Version of affected browser(s),operating system(s), npm, node and ngrx:

latest

Other information:

@brandonroberts
Copy link
Member

Can you make a small repro?

@majo44
Copy link
Author

majo44 commented Oct 4, 2017

Sample added.
http://plnkr.co/edit/SbecXWSzFMnSRA9JFQ0i

@brandonroberts
Copy link
Member

This issue has already been fixed in master and will be in the next release. #355

@soyuka
Copy link

soyuka commented Oct 19, 2017

When will it be released? Thanks.

@antl3x
Copy link

antl3x commented Mar 31, 2018

I keep getting this error even with new master.

@demirtasg
Copy link

this issue is still not resolved

@pfeileon
Copy link

pfeileon commented Apr 8, 2024

I'm refactoring an app from excessive resolver-use to NgRx and get unexpected navigation cancelled events, as well, even though the resolvers themselves don't even inject the store. Since I'll make all resolvers non-blocking and use them as a hook to dispatch actions more or less declaratively via the route config, it won't be an issue for me, but there's definitely still something wrong.

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

No branches or pull requests

6 participants