You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Bug: certain usage of $location causes infinite digest loop #12168
Seems like the location.replace() is not happening immediately, but after a short time period, that is enough to cause infinite digest, as it is detected as a location change on each check.
Or it can be solved by saving the actual URL (that should be there) and returning that instead of reading location.href directly. (I'm checking if this works now)
Found a working solution that is similar to the reloadLocation exception, but taking a closer look revealed that when the only search param is reset in the example above ($location.search('some_param', null);) then the page is getting reloaded as stripping the # from the end of the URL makes the browser (Chrome in my case) thinking that the URL changed and it needs to load the "new" page. The infinite digest is happening right before the page is getting reloaded.
What do you think about making sure that once the # got in the URL making sure that it won't get stripped later?
This issue seems to be present since v1.2.27. Running with v1.2.26 is not triggering infinite digest / page reload (though I'm not certain any more what URL change is causing a page reload any more :) ).
Removing the condition solves the infinite digest issue, but the page is still reloading... That's how far I could get for now. I hope I can find some time next week to pick up investigating.
I can't reproduce this any more on v1.5.10/v1.6.1. It was likely fixed at some point.
If this is still an issue, pleae open a new bug report with an updated reproduction.
Activity
robmazan commentedon Jun 19, 2015
Seems like the location.replace() is not happening immediately, but after a short time period, that is enough to cause infinite digest, as it is detected as a location change on each check.
I wonder if checking URL change against the actual URL (instead of
lastBrowserUrl) would cause any issues?robmazan commentedon Jun 19, 2015
Or it can be solved by saving the actual URL (that should be there) and returning that instead of reading
location.hrefdirectly. (I'm checking if this works now)robmazan commentedon Jun 19, 2015
Found a working solution that is similar to the
reloadLocationexception, but taking a closer look revealed that when the only search param is reset in the example above ($location.search('some_param', null);) then the page is getting reloaded as stripping the # from the end of the URL makes the browser (Chrome in my case) thinking that the URL changed and it needs to load the "new" page. The infinite digest is happening right before the page is getting reloaded.What do you think about making sure that once the # got in the URL making sure that it won't get stripped later?
robmazan commentedon Jun 19, 2015
This issue seems to be present since v1.2.27. Running with v1.2.26 is not triggering infinite digest / page reload (though I'm not certain any more what URL change is causing a page reload any more :) ).
robmazan commentedon Jun 19, 2015
Ok, so that specific change introduced the infinite digest in this setup: v1.2.26...v1.2.27#diff-ab8fe92910b19f1815d419aead809672R171
Removing the condition solves the infinite digest issue, but the page is still reloading... That's how far I could get for now. I hope I can find some time next week to pick up investigating.
robmazan commentedon Jun 22, 2015
One more detail:
In v1.2.26 the code hits that line: v1.2.26...v1.2.27#diff-ab8fe92910b19f1815d419aead809672L158
While in v1.2.27 hits that one: v1.2.26...v1.2.27#diff-ab8fe92910b19f1815d419aead809672R175
So a
history.replaceState()call got accidentally replaced with alocation.replace()- that's the cause of the reloading.gustavokloh commentedon Jun 30, 2015
Returning the
history.replaceState()not solve?Or is there some other reason to maintain
location.replace()?robmazan commentedon Jul 1, 2015
I suspect it has to do something with this comment:
angular.js/src/ng/browser.js
Lines 159 to 162 in 17d8a52
I had no time to setup this specific case locally and experiment with it, but it's on my list. :)
gkalpak commentedon Jan 4, 2017
I can't reproduce this any more on v1.5.10/v1.6.1. It was likely fixed at some point.
If this is still an issue, pleae open a new bug report with an updated reproduction.