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

evaluateAsync doesn't return rejected promises properly #976

Closed
patrickhulce opened this issue Nov 18, 2016 · 6 comments
Closed

evaluateAsync doesn't return rejected promises properly #976

patrickhulce opened this issue Nov 18, 2016 · 6 comments

Comments

@patrickhulce
Copy link
Collaborator

Partially discussed in #965

Repro steps:

  1. Add a bug in gatherers/dobetterweb/links-blocking-first-paint.js or any other browser eval'd function that should cause the promise to be rejected
  2. Run lighthouse with dbw audits enabled.
  3. Observe that the debug string is tags.reduce is not a function or some similar unhelpful message masking the underlying issue.

Issue lies in JSON serialization of the result and the rejected promise being converted to an object like below instead of a rejected promise see driver.js.

{
  "result": {
    "type": "object",
    "value": {}
  },
  "exceptionDetails": {
    "exceptionId": 1,
    "text": "Uncaught (in promise)",
    "lineNumber": 0,
    "columnNumber": 0,
    "stackTrace": {
      "callFrames": []
    },
    "exception": {
      "type": "object",
      "value": {}
    }
  }
}
@brendankenny
Copy link
Member

brendankenny commented Nov 18, 2016

If we fix this we need to be especially sure it's fixed in both CLI and extension.

The unhelpful promise rejection info is really unfortunate. Looks like it may be a devtools bug? It would be nice to have error message, stack trace, etc

@brendankenny
Copy link
Member

In #965 the weird result.wasThrown check in the extension connection came up.

I can only find wasThrown in one place in the protocol, when fetching the properties of an object, and that result doesn't have an exceptionDetails property, so it's not entirely clear if that's ever actually hit in the extension codepath. Looking at the git blame for it, the reason it was added isn't abundantly clear (and we no longer do what we were doing there), so it's possible it's a red herring and just needs to be removed.

@brendankenny
Copy link
Member

so it's possible it's a red herring and just needs to be removed

this is being removed in #977

@brendankenny
Copy link
Member

@patrickhulce this was fixed for evaluateAsync in #965, right?

We could close or we could expand the issue scope to all the protocol methods we currently use that return an object with possible exceptionDetails

@patrickhulce
Copy link
Collaborator Author

Yeah that was pretty much just a stop gap since anything that's an actual Error object would be totally empty but in that case we were explicitly rejecting with just a string, I think expanding the scope to properly handle those errors makes sense

patrickhulce added a commit to patrickhulce/lighthouse that referenced this issue Nov 23, 2016
addresses GoogleChrome#1000 and GoogleChrome#976

1. Ensures all `Runtime.evaluate` calls result in the native Promise
2. Transforms all errors produced during the evaluation to a standard object that can be rejected by our driver wrapper
patrickhulce added a commit to patrickhulce/lighthouse that referenced this issue Nov 23, 2016
addresses GoogleChrome#1000 and GoogleChrome#976

1. Ensures all `Runtime.evaluate` calls result in the native Promise
2. Transforms all errors produced during the evaluation to a standard object that can be rejected by our driver wrapper
patrickhulce added a commit to patrickhulce/lighthouse that referenced this issue Nov 24, 2016
addresses GoogleChrome#1000 and GoogleChrome#976

1. Ensures all `Runtime.evaluate` calls result in the native Promise
2. Transforms all errors produced during the evaluation to a standard object that can be rejected by our driver wrapper
patrickhulce added a commit to patrickhulce/lighthouse that referenced this issue Nov 24, 2016
addresses GoogleChrome#1000 and GoogleChrome#976

1. Ensures all `Runtime.evaluate` calls result in the native Promise
2. Transforms all errors produced during the evaluation to a standard object that can be rejected by our driver wrapper
patrickhulce added a commit to patrickhulce/lighthouse that referenced this issue Nov 24, 2016
addresses GoogleChrome#1000 and GoogleChrome#976

1. Ensures all `Runtime.evaluate` calls result in the native Promise
2. Transforms all errors produced during the evaluation to a standard object that can be rejected by our driver wrapper
@brendankenny
Copy link
Member

#1037 has a nice solution to this

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

No branches or pull requests

2 participants