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

Exception thrown from _fullyScopeQueryParams #14010

Closed
alisdair opened this issue Aug 3, 2016 · 5 comments · Fixed by #14068
Closed

Exception thrown from _fullyScopeQueryParams #14010

alisdair opened this issue Aug 3, 2016 · 5 comments · Fixed by #14068

Comments

@alisdair
Copy link
Contributor

alisdair commented Aug 3, 2016

Since upgrading to 2.7, our app has been throwing errors in production on some transitions. We have around 600 errors recorded in the past week.

I haven't been able to reproduce these in a development environment, so all I have to go on is a stack trace. But it looks to me like there's something going askew on the path from transitionTo to the new _fullyScopeQueryParams introduced in #13273 by @raytiley.

The error we're seeing is:

Cannot use 'in' operator to search for 'type' in undefined

(The exact query param searched for varies.)

Looking at the definition of this method, the only use of the in operator is against its queryParams argument, which therefore must somehow be undefined.

Backing up the stack trace, this parameter is set in transitionTo, and the only path I can see where it could possibly be undefined is this code:

if (possibleQueryParams && possibleQueryParams.hasOwnProperty('queryParams')) {
  queryParams = args.pop().queryParams;
} else {
  queryParams = {};
}

I can't find anything in our app or dependencies that is doing strange things with queryParams in links or transitions, but my knowledge of the router guts ends here.

So while I'm stuck about the root cause, all I can suggest is that we could add a fallback. If the queryParams property of the popped arg isn't an object, default to {}, as in the other branch of the if statement.

Would that approach be acceptable? Or can anyone suggest further steps I could take to track down the root cause of the bug?

@jcbvm
Copy link

jcbvm commented Aug 4, 2016

Having the same. But from what I can see it's a timing issue because of the inconsistent reproduction case.

@supersabillon
Copy link

Also having this issue since upgrading to 2.7

alisdair added a commit to alisdair/ember.js that referenced this issue Aug 6, 2016
@chriscareycode
Copy link

Having the same issue after upgrading to 2.7.0

alisdair added a commit to alisdair/ember.js that referenced this issue Aug 15, 2016
alisdair added a commit to alisdair/ember.js that referenced this issue Aug 15, 2016
@rwjblue rwjblue added the Bug label Aug 15, 2016
rwjblue pushed a commit that referenced this issue Aug 15, 2016
(cherry picked from commit b229ca9)
rwjblue pushed a commit that referenced this issue Aug 15, 2016
rwjblue pushed a commit that referenced this issue Aug 15, 2016
toddjordan pushed a commit to toddjordan/ember.js that referenced this issue Sep 9, 2016
toddjordan pushed a commit to toddjordan/ember.js that referenced this issue Sep 9, 2016
webark pushed a commit to webark/ember.js that referenced this issue Oct 6, 2016
webark pushed a commit to webark/ember.js that referenced this issue Oct 6, 2016
@Frozenfire92
Copy link
Contributor

Frozenfire92 commented May 17, 2018

Still experiencing this bug in Ember 3.1.2 and not able to come up with a consistent reproduction strategy. As I've had this happen when transitioning between routes that don't have query parameters. (we have a global qp on the application controller, but has never been used when I experience this error

Uncaught TypeError: Cannot use 'in' operator to search for 'qpKey' in undefined
    at Class._fullyScopeQueryParams (router.js:664)
    at Class._processActiveTransitionQueryParams (router.js:586)
    at Class._doTransition (router.js:556)
    at Class.transitionTo (routing.js:18)

which points to this line in _fullyScopeQueryParams

var presentProp = qp.prop in queryParams && qp.prop || qp.scopedPropertyName in queryParams && qp.scopedPropertyName || qp.urlKey in queryParams && qp.urlKey;

@Frozenfire92
Copy link
Contributor

Thought of a possible easy fix

change this

(qp.prop in queryParams && qp.prop) ||
(qp.scopedPropertyName in queryParams && qp.scopedPropertyName) ||
(qp.urlKey in queryParams && qp.urlKey);

to check for queryParams existence first

(queryParams && qp.prop in queryParams && qp.prop) ||
(queryParams && qp.scopedPropertyName in queryParams && qp.scopedPropertyName) ||
(queryParams && qp.urlKey in queryParams && qp.urlKey);

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

Successfully merging a pull request may close this issue.

7 participants