-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Random "Cannot read property 'params' of undefined" errors #2327
Comments
Can you find where the error is being thrown as I'm not sure what the trace is showing |
What's in "Controllers.Login"? And which view does this error occur in, because it looks like whatever is going on, there's a "params" property not being set, or failed to set. |
@shonatodc it's a controller wrapper around the Login service (that holds current user access tokens). nothing related to @eddiemonge the exception on Google Analytics only accept 255 chars of information, that's why there isn't a complete stacktrace. Since I couldn't reproduce locally, I assume the |
Its hard to tell but it seems like there is a call to a |
I have the same problem. It occurs in
It occurs when I use FYI: @eddiemonge |
Can you do a plnkr showing that or what you mean by that? |
@eddiemonge It's simple use case. I want to create URL in my controller to the state with some params. When I use In that case, I got I didn't get that error when I debugged my code. It occurs on production. I think that we should add some checking here or create parents array in another way. |
@mrzepinski I think it's a race condition, while the iteration of parents is happening, the transition of routes mutates the array at the same time, making the Line 99 in 4da7e59
if (!parents[i] || !parents[i].params) continue;
|
@pocesar Did you submit a PR for your suggested fix above? We're seeing exactly the same issue in our app occasionally, usually traced to an element with ui-sref. Might just be a fluke, but so far these "TypeError Cannot read property 'params' of undefined" errors in our log are always when user is on Chrome on Windows. I haven't been able to trigger this problem with Chrome on my Mac. At first I thought it was isolated to Chrome 46.0.2490.80 on Windows, but going further back in the logs I see the same error occurring on older versions of Chrome (but always on Windows). |
@rickyrobinson I didn't yet, I was reading the source trying to pinpoint the problem. AFAIK the directives seems to be using a modified version of the object that gets passed to the service, and that might be generating the race condition (on calls to |
@pocesar I found what was triggering the issue in my case. Hope it can help others. Turns out in my case it was being triggered by a workaround I had to wrote because Prototype.js was messing with Array.prototype.toJSON. Since I can't drop Prototype because my code runs on arbitrary websites as a widget I solved the issue (on our website) narrowing the workaround by checking if the "bad" version of Prototype is present. Previously I had this:
Now I have this
By doing this our app does not suffer from this issue anymore (we don't use Prototype). But anyone using ui.router and messing with Array.prototype will probably suffer from it until the PR that solves it for good gets merged. |
+1 Line 99 in 4da7e59
if (!parents[i].params) continue;
|
We experience this issue on our website too. Never seen this issue in development, but pops up in production sometimes. Always triggered by a call to |
again, it would be helpful if someone can make a plnkr demonstrating this so |
I would love to create a Plunkr, but the weird thing is that I never encounter this issue myself, but some of our users seem to be affected by it. |
This error is currently one of the top 3 of our most commonly logged errors. It has occurred hundreds of times in our app on production, but I have never managed to reproduce it myself neither on production nor locally, so it's really not a matter of us not willing to create a Plunkr ;) Summing up observations:
Solution from #2327 (comment) is what I came up with as well. Would it break anything if this change was merged in? I would not like to keep a fork just for this single line of code... |
@piotrd That's weird. Sure, submit a PR. |
fix(common.js): "Cannot read property 'params' of undefined" errors Closes #2327
My client side analytics is getting filled with the same errors that seems to be related to ui-router
I can't reproduce this on local machine, so I'm a little stumped
The text was updated successfully, but these errors were encountered: