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

StoreRouterConnectingModule creates an infinite Loop and makes Browser crash #500

Closed
nickwinger opened this issue Oct 18, 2017 · 2 comments

Comments

@nickwinger
Copy link

nickwinger commented Oct 18, 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?

When using the StoreRouterConnectingModule with some parent/child route resolve there is an infinite Loop

Expected behavior:

No infinite Loop

Minimal reproduction of the problem with instructions:

We have a HomeComponent (loaded with a route, let's call it parent)
And a ShowInfoComponent (loaded lazy on a child route, let's call it child)
And we have domain data on the server which gets loaded async by an effect into the store.
Now i don't know if it's the best practice, but to have the domain data loaded async right at the beginning of the HomeComponent, i created a resolve on this route, to wait and load the domain data.
Now when the parent route gets activated this domain data is present.
The child route also has a resolve on it, it needs to get some Info from the domain-data.
This scenario creates an infinite loop when the StoreRouterConnectingModule is loaded, without it, everything works as espected.
I get a lot of ROUTERNAVIAGTION_CANCELLED, i don't know why, as nothing gets cancelled.
The router just waits for the domain data on the HomeComponent via the resolve, and then it waits on the child route also for the resolve to read some info out of the store (the domain data gets written into the ngrx store)

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

@angular: 4.4.4
"@ngrx/effects": "^4.0.5",
"@ngrx/router-store": "^4.0.4",
"@ngrx/store": "^4.0.3",
"rxjs": "5.4.2",
npm 5.3.0
node 8.6.0
windows 7
chrome newest

Other information:

I guess it has something to do, that the store gets updated (an action is dispatched) inside a route-guard / route-resolver

Update:
The problem dissappears if you remove the routerReducer from the State. so just haveing the StoreRouterConnectingModule works without the routerReducer

@rupeshtiwari
Copy link
Contributor

rupeshtiwari commented Oct 18, 2017

Hi @nickwinger
I had the same requirement and I wrote an EFFECT which subscribes on ROUTENAVIGATION_UPDATE and fetches the domain data from server api and dispatches an load_success action. Reducer then updates the state with domain data. Hence by the time component loads up component get the domain data from the state via selectors.

@brandonroberts
Copy link
Member

This issue has already been fixed in master and will be in the next release, which should land this week.

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

3 participants