-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Infinite digest loop occurring on first run of app when running grunt server #10423
Comments
Could be related to this issue angular-ui/ui-router#1616 |
ping @petebacondarwin |
tentatively moving this to 1.3.8 but I don't expect it will be fixed immediately --- I think this is a duplicate issue too, lemme find the other |
@jared will can you create a reproduction to demonstrate this? |
@petebacondarwin I have been trying to but unsuccessfully so far. |
I suspect it is related to the $location rewriting of the path. What is you $location config? Are you using HTML5Mode? |
I think that my issue is somehow related #10405 The problem seems to involve the way $location deals with hashbang URLs. |
I am not using HTML5Mode no. |
@jaredwilli Can you share the code somehow ? If you can't do Plnkr, how about bundling your code and shipping it to me ? Because I had the same problem some time ago, but unfortunately I lost the code. I'll try to reproduce this. |
I have put this into the Icebox since there is no reproduction and there is no one else experiencing this problem. |
I think I was able to reproduce it (it's a much broader usecase - nothing to do with grunt server). Basically, (I think) it happens when you have an empty This is happening since v1.3.6 (and up to at least v1.4.0) and the problem is (afaict) in ng/browser.js on this line: location.hash = getHash(url); This is what happens:
Here is where the issue starts:
(Assuming it works the same way in the rest of the supported browsers), the fix should be simple: Just keep the leading function getHash(url) {
var index = url.indexOf('#');
//return index === -1 ? '' : url.substr(index + 1);
return index === -1 ? '' : url.substr(index);
} /cc @petebacondarwin (since you are currently working on |
@jaredwilli and @gkalpak - can you see if 91b6022 fixed this? |
I see that it doesn't on the live reproduction. |
I no longer have access to the code base that I was seeing this issue with. I have a different job now so can't test if this works. |
… no hashPrefix The `window.location.hash' setter will strip of a single leading hash character if it exists from the fragment before joining the fragment value to the href with a new hash character. This meant that if we want the fragment to lead with a hash character, we must do `window.location.hash = '##test'` to ensure that the first hash character in the fragment is not lost. The `$location.hash` setter works differently and assumes that the value passed is the the full fragment, i.e. it does not attempt to strip off a single leading hash character. Previously, if you called, `$location.hash('#test')`, the leading hash was being stripped and the resulting url fragment did not contain this hash: `$location.hash()`, then became 'test' rather than `#test`, which led to an infinite digest. Closes angular#10423
I have a fix for this, using @gkalpak's suggestion. Please can you review? |
#12145 seems to fix my live reproduction scenario. |
… no hashPrefix The `window.location.hash' setter will strip of a single leading hash character if it exists from the fragment before joining the fragment value to the href with a new hash character. This meant that if we want the fragment to lead with a hash character, we must do `window.location.hash = '##test'` to ensure that the first hash character in the fragment is not lost. The `$location.hash` setter works differently and assumes that the value passed is the the full fragment, i.e. it does not attempt to strip off a single leading hash character. Previously, if you called, `$location.hash('#test')`, the leading hash was being stripped and the resulting url fragment did not contain this hash: `$location.hash()`, then became 'test' rather than `#test`, which led to an infinite digest. Closes angular#10423 Closes angular#12145
… no hashPrefix The `window.location.hash' setter will strip of a single leading hash character if it exists from the fragment before joining the fragment value to the href with a new hash character. This meant that if we want the fragment to lead with a hash character, we must do `window.location.hash = '##test'` to ensure that the first hash character in the fragment is not lost. The `$location.hash` setter works differently and assumes that the value passed is the the full fragment, i.e. it does not attempt to strip off a single leading hash character. Previously, if you called, `$location.hash('#test')`, the leading hash was being stripped and the resulting url fragment did not contain this hash: `$location.hash()`, then became 'test' rather than `#test`, which led to an infinite digest. Closes #10423 Closes #12145
… no hashPrefix The `window.location.hash' setter will strip of a single leading hash character if it exists from the fragment before joining the fragment value to the href with a new hash character. This meant that if we want the fragment to lead with a hash character, we must do `window.location.hash = '##test'` to ensure that the first hash character in the fragment is not lost. The `$location.hash` setter works differently and assumes that the value passed is the the full fragment, i.e. it does not attempt to strip off a single leading hash character. Previously, if you called, `$location.hash('#test')`, the leading hash was being stripped and the resulting url fragment did not contain this hash: `$location.hash()`, then became 'test' rather than `#test`, which led to an infinite digest. Closes angular#10423 Closes angular#12145
I tried to update my app to use 1.3.6 but when I do for some reason an infinite digest loop happens when I run grunt server and the app opens in the browser. It appears to redirect in the url bar over and over before it shows anything until finally it shows the page. Looking at the console I can see there are several errors for this.
When I refresh the page though, it doesn't happen. Only on the first run of the app.
The last version of angular that it doesn't do this in is 1.3.3.
The text was updated successfully, but these errors were encountered: