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

Unhandled promise rejection (lighthouse-core/gather/fetcher.js) #11033

Closed
mikedijkstra opened this issue Jun 29, 2020 · 2 comments · Fixed by #11036
Closed

Unhandled promise rejection (lighthouse-core/gather/fetcher.js) #11033

mikedijkstra opened this issue Jun 29, 2020 · 2 comments · Fixed by #11036

Comments

@mikedijkstra
Copy link
Contributor

We're seeing a number of errors being thrown from lighthouse-core/gather/fetcher.js as unhandled promise rejections.

Examples of errors:

  • Protocol error (Fetch.failRequest): Fetch domain is not enabled
  • Protocol error (Fetch.continueRequest): Invalid InterceptionId.
  • Error: Invalid response status code: 404
  • Invalid response status code: 403
  • Invalid response status code: 301
Error output
Unhandled Rejection at: Promise Promise {
  <rejected> Error: Invalid response status code: 404
      at ./node_modules/lighthouse/lighthouse-core/gather/fetcher.js:119:18
      at Fetcher._onRequestPaused (./node_modules/lighthouse/lighthouse-core/gather/fetcher.js:75:13)
      at EventEmitter.emit (events.js:315:20)
      at EventEmitter.emit (domain.js:482:12)
      at Driver._handleProtocolEvent (./node_modules/lighthouse/lighthouse-core/gather/driver.js:299:24)
      at EventEmitter.emit (events.js:315:20)
      at EventEmitter.emit (domain.js:482:12)
      at CalibreProtocol.emitProtocolEvent (./node_modules/lighthouse/lighthouse-core/gather/connections/connection.js:148:24)
      at CalibreProtocol.handleRawMessage (./node_modules/lighthouse/lighthouse-core/gather/connections/connection.js:113:12)
      at WebSocket.<anonymous> (./node_modules/lighthouse/lighthouse-core/gather/connections/cri.js:72:37)
} reason: Error: Invalid response status code: 404
    at ./node_modules/lighthouse/lighthouse-core/gather/fetcher.js:119:18
    at Fetcher._onRequestPaused (./node_modules/lighthouse/lighthouse-core/gather/fetcher.js:75:13)
    at EventEmitter.emit (events.js:315:20)
    at EventEmitter.emit (domain.js:482:12)
    at Driver._handleProtocolEvent (./node_modules/lighthouse/lighthouse-core/gather/driver.js:299:24)
    at EventEmitter.emit (events.js:315:20)
    at EventEmitter.emit (domain.js:482:12)
    at CalibreProtocol.emitProtocolEvent (./node_modules/lighthouse/lighthouse-core/gather/connections/connection.js:148:24)
    at CalibreProtocol.handleRawMessage (./node_modules/lighthouse/lighthouse-core/gather/connections/connection.js:113:12)
    at WebSocket.<anonymous> (./node_modules/lighthouse/lighthouse-core/gather/connections/cri.js:72:37)
(node:25717) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 10)
Error: Invalid response status code: 404
    at ./node_modules/lighthouse/lighthouse-core/gather/fetcher.js:119:18
    at Fetcher._onRequestPaused (./node_modules/lighthouse/lighthouse-core/gather/fetcher.js:75:13)
    at EventEmitter.emit (events.js:315:20)
    at EventEmitter.emit (domain.js:482:12)
    at Driver._handleProtocolEvent (./node_modules/lighthouse/lighthouse-core/gather/driver.js:299:24)
    at EventEmitter.emit (events.js:315:20)
    at EventEmitter.emit (domain.js:482:12)
    at CalibreProtocol.emitProtocolEvent (./node_modules/lighthouse/lighthouse-core/gather/connections/connection.js:148:24)
    at CalibreProtocol.handleRawMessage (./node_modules/lighthouse/lighthouse-core/gather/connections/connection.js:113:12)
    at WebSocket.<anonymous> (./node_modules/lighthouse/lighthouse-core/gather/connections/cri.js:72:37)

I'm seeing the error in Node and when using the Lighthouse CLI.

Provide the steps to reproduce

Run:

lighthouse https://www.clarin.com/deportes/basquet/ginobili-volvio-hacer-magia-definicion-exquisita_0_H16J9aAaZ.html --view

What is the current behavior?

Lighthouse returns Unhandled Rejection. Reason: Error: Invalid response status code: 404. See full output.

What is the expected behavior?

Lighthouse report is generated and opened in the browser

Environment Information

  • Affected Channels: CLI, Node
  • Lighthouse version: 6.1
  • Chrome version: 83.0.4103.116
  • Node.js version: 12.18.0
  • Operating System: Mac, Linux
@patrickhulce
Copy link
Collaborator

patrickhulce commented Jun 29, 2020

Thanks for filing @mikedijkstra! The sendCommand ones are an easy fix but I'm not immediately seeing how the invalid status code ones are unhandled 🤔 we'll have to investigate.

My preliminary investigation results:

  • The only place we use the fetcher is in source maps where it is await'd properly, so it must be internal to fetcher.
  • I was guessing that requestInterceptionPromise was rejecting after our timeout rejected and that somehow leads to the unhandled rejection.
    return Promise.race([
    timeoutPromise,
    requestInterceptionPromise,
    ]).finally(() => clearTimeout(timeoutHandle));
  • This doesn't hold up with my understanding of Promise.race though, and toy example won't repro either... not sure how it's happening
const rejectIn1s = new Promise((r, reject) => setTimeout(() => reject('foo'), 1000)) // this doesn't lead to an unhandled promise rejection
const resolvein500ms = new Promise(r => setTimeout(r, 500))

Promise.race([rejectIn1s, resolvein500ms])
  .then(() => console.log('done'))
  .finally(() => console.log('finally'))

@connorjclark
Copy link
Collaborator

image
image (1)

It's being rejected before the evaluation ends.

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.

4 participants