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 when doing a state transition from another state #1040

Closed
phindmarsh opened this issue Apr 23, 2014 · 5 comments
Closed

Infinite loop when doing a state transition from another state #1040

phindmarsh opened this issue Apr 23, 2014 · 5 comments

Comments

@phindmarsh
Copy link

I've just run into an infinite loop when using $state.go() from within a state controller to navigate to another state.

A plunkr showing the problem is here (one using ui-router at 0.2.10 is here)

The second one works as expected, and the first causes the ui-view to render loads of times, eventually exhausting the call-stack. (Open a console to see what I mean).

I spent some time digging into the cause, and it looks like its something to do with the resolveState() function around line 1135 of state.js, but I'm not sure (basically thats as far down as I got)

Any thoughts?

@phindmarsh
Copy link
Author

Looks like it was potentially introduced in this commit:

54004a1 (PR #936)

(editing the plunkr to use the SHA from the commit before seems to work fine, and breaks with the one above)

@phindmarsh
Copy link
Author

Aaand it looks like it is solved by wrapping the call to $state.go() in a stateChangeSuccess event handler (plunkr)

$scope.$on('$stateChangeSuccess', function () {
    $state.go('statename');
}); 

(source)

@nateabele
Copy link
Contributor

I just checked your version of the Plunkr against 0.2.10. I'm not sure what I should be seeing, but there was no error and the output (from what I could tell by reading the code) appeared to be as expected.

@phindmarsh
Copy link
Author

The version using 0.2.10 is the correctly working version. The error I'm referring to is present in the master branch (specifically, commits after 54004a1)

Heres some screenshots of the error as I see it: https://cloudup.com/c7vzH4inkuk (The one with heaps of repeating lines is the broken one.)

@eddiemonge
Copy link
Contributor

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