Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

AngularJS - 1.1.2 - ngView/location/route problem with IE 9 (I think "10 $digest() iterations reached" is just the first part of the problem)... #2007

Closed
swbannerman opened this issue Feb 13, 2013 · 20 comments

Comments

@swbannerman
Copy link

I adjusted this example slightly to demonstrate the problem(s)...I think there may be two:

http://docs.angularjs.org/api/ng.directive:ngView

I've stored the files to replicate the problem(s) here:

http://plnkr.co/edit/Gc6ES0boirDdfHAZAATl

They do not appear to work directly from the plunker preview (as the templates don't seem to get loaded properly); however, if you zip/download/install them and then run the web-server.js, you should be able to replicate them.

With "web-server.js" running, try to load "localhost:8000/index.html" in Chrome and Firefox (and presumably any browser with HTML5 mode capabilities), it works as expected, with the navigation clicks causing the proper template to be loaded into the ngView (according to the routeProvider).

However, when I run it in IE 9 (and maybe other non-HTML5 mode browsers), I get the "10 digest() iterations reached" problem (see log/ie9.error-console.txt for the copy from the IE 9 "F12 Developer Tools" console).

After looking at the source code, I saw why the max iterations were reached...the oldUrl (which comes from location.href via the browser.url() getter) does not have the hash (or hashbang) but the location.absUrl() does have it and thus they're always considered different here:

    $rootScope.$watch(function $locationWatch() {
      var oldUrl = $browser.url();
      var currentReplace = $location.$$replace;

      if (!changeCounter || oldUrl != $location.absUrl()) {

But, inside the browser url() function (setter behavior in particular), nothing happens because it thinks the old and new values are the same, because it compares the input url with the lastBrowserUrl rather than the location.href.

  self.url = function(url, replace) {
    // setter
    if (url) {
      if (lastBrowserUrl == url) return;

So, I think that's the first problem...I don't know enough about the framework or the specific intended behavior to know what should happen, but it seems like the watch should be able to recognize that no changes happened when html5Mode is set to true for a browser like IE 9 that does not support it.

I put in a "fix" to stop this unintended iteration (etc/angular.js.patch) and this got rid of the error in the console but still did not load the index.html and this did not allow me to try the navigation links. I think this is the second problem; however, it could be because I didn't fix the first problem properly.

Finally, thanks for all of your work on this fine product (and sorry for the formatting of parts of this message).

@jprystowsky
Copy link

For what it's worth, I'm having this issue as well, with no apparent resolution that I can find.

@ramandv
Copy link

ramandv commented Apr 1, 2013

Same issue

@hcabnettek
Copy link

I am also having this issue both in IE8 and IE9. IE10 seems to be ok.

@silvanm
Copy link

silvanm commented Apr 18, 2013

I encountered the same problem. You patch helped. Thanks a lot! You saved my life! :-)

@just-boris
Copy link
Contributor

I solved this issue without editing angular code. I added following code before angular loading

if (!history.pushState) {
    //if hashbang url found and we are not on our base then go to base
    if (window.location.hash.charAt(1) === "!" && window.location.pathname !== '/') {
        window.location.replace('/#!' + window.location.hash.substring(2));
    }
    //if hasbang not found then convert link to hashbang mode
    if(window.location.hash.charAt(1) !== "!") {
        window.location.replace('/#!' + window.location.pathname + window.location.search+window.location.hash);
    }
}

It's not quite right, but doesn't require changing angular source and let it working until this issue will be fixed

@pvasek
Copy link
Contributor

pvasek commented May 24, 2013

Just submitted pull request for that #2782.

@ceryash
Copy link

ceryash commented May 30, 2013

I am facing this issue even in IE10

@seiyer
Copy link

seiyer commented Jun 13, 2013

We are also facing the same issue and fix so far?

@btford btford closed this as completed Aug 24, 2013
@btford
Copy link
Contributor

btford commented Aug 24, 2013

As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months.

Please try the newest versions of Angular (1.0.8 and 1.2.0-rc.1), and if the issue persists, comment below so we can discuss it.

Thanks!

@hotrannam
Copy link

I have a problem with IE9 where it runs into infinite digest when I click on the link to navigate to home page. I observer the flow below is interesting to me when I click on the link above from project page.

project page -> home page -> infinite digest -> 404 page configured with otherwise of $urlRouterProvider -> home page.

404 page appears in a few seconds and auto redirect to home page.

Chrome/FF works well, but IE9. Currently I am using version 1.0.7. Even with version 1.0.8, this issue still happens.

@btford
Copy link
Contributor

btford commented Aug 29, 2013

The fix described here was in fact merged long ago.

@boajer
Copy link

boajer commented Nov 29, 2013

Issue still happens even in 1.2.3

@jbachelor
Copy link

Still seeing this issue (IE 10 is what I've specifically tested with)... We've tried 1.2.7, 1.2.8, and 1.2.9. Since this is listed as "closed", is there another open thicket for this issue?

@elennaro
Copy link

elennaro commented Apr 6, 2014

Still Facing this ussue 1.2.12

@cmorner
Copy link

cmorner commented May 13, 2014

Still facing this Issue 1.2.0-rc.3

@caitp
Copy link
Contributor

caitp commented May 13, 2014

So, the docs app is using ngRoute, and I verified that it works correctly in IE9 a while ago when merging a $location-related fix for IE9, which leads me to believe that the problem is more complicated than is described.

Could one of you try and put together a minimal reproduction on heroku or something? (Plunkr would ordinarily be fine, but this sounds like an HTML5-mode issue), and be sure to also make the source code for the heroku server available.

Also, be sure to use a recent version of Angular in the reproduction, either 1.2.16 or 1.3

(And yes, the reproduction does need to be hosted somewhere so that I can play around with it via saucelabs, because I don't have access to a local IE9)

@BrianGenisio
Copy link

+1. We are seeing this issue with Angular 1.2.15 on IE8, IE9, IE10, and IE11

I've read a lot about this issue, but it doesn't appear that anyone really has a good handle on it. Can someone summarize what is happening here? I mean, I understand the that $watchLocation function is returning a different changeCounter every digest, but is this because IE doesn't update the URL synchronously?

@BrianGenisio
Copy link

I should add that I found the condition that exercises this bug. My code was writing to $window.location = newUrl; to change the URL, which caused the infinite $digest problem. By changing it to $location.path(newUrl); the bug doesn't get exercised.

@ghost
Copy link

ghost commented Jun 19, 2014

@BrianGenisio great work, as this seems to sort out the issue, I still have a glitch, but I thing that is my own issue to resolve. I think the AngulatJS tutorials and documentation should tell people never to use "window.location", and even using $window dod not work for me, but the strategy should always be via $location - make sense as the AngularJS team can encapsulate the crap, as they do with so much other DOM related stuff. I love Angular, and this is the first really annoying thing as unfortunately my customers have people still using IE (yeah!).

Colin

@LuizPanariello
Copy link

I'm using AngularJS v1.2.25 with $location.path('/coolurl'); with $locationProvider.html5Mode(false).hashPrefix('!'); and on route change that error persists, anyone have any ideia on how to solve it? This problem happens in IE8 and IE9...

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

No branches or pull requests