question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose page functions to custom gatherers

See original GitHub issue

Provide the steps to reproduce

  1. Run LH on https://bristololdvic.org.uk with my massive wrapper function and custom gatherer/audit library…

What is the current behavior?

Got a custom audit to test for http status code- snippet below.

const mainResource = await artifacts.requestMainResource({URL: artifacts.URL, devtoolsLog});
 const statusCode = mainResource.statusCode;

 if (statusCode >= 500 && statusCode < 600) {
   return {
     rawValue: false,
     displayValue: `Page returned HTTP status code of ${statusCode}`,
   };
 }

 return {
   rawValue: true,
   displayValue: `Page returned HTTP status code of ${statusCode}`,
 };

What happens is artifacts.requestMainResource({URL: artifacts.URL, devtoolsLog}) rejects with TypeError: devtoolsLog.forEach is not a function

This is nothing to do with the arguments I pass in to the method; I have a feeling the issue is with https://github.com/GoogleChrome/lighthouse/blob/1098f952d5c75b22668aa572532415f81d2817af/lighthouse-core/lib/network-recorder.js#L355

The rejection of this promise then exits this function prematurely, and rawValue will be null which isn’t handy for further use!

What is the expected behavior?

Expected behaviour is artifacts.requestMainResource({URL: artifacts.URL, devtoolsLog}) to resolve, returning the main resource so it’s parameters can be used for tests in audits.

Environment Information

  • Affected Channels:
  • Lighthouse version: lighthouse@2.9.4
  • Node.js version: v10.14.1
  • Operating System: Windows 10 Home

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
patrickhulcecommented, Feb 25, 2019

@upugo-dev should be AFAIK

0reactions
upugo-devcommented, Apr 16, 2019

we decided not to do this for now.

We can encourage folks to head to page-functions.js and copy/paste out of it, but fundamentally these are just regular functions to be run in a web page. There’s no Lighthouse magic sauce it would be helpful for folks to have access to, so let’s not commit to it as part of our API.

That makes a lot of sense, thanks for following up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

INFORMATION AND ITS ROLE IN HUNTER-GATHERER ...
Information and Its Role in Hunter-Gatherer Bands, edited by. Robert Whallon, William A. Lovis, and Robert K. Hitchcock. Volume 4.
Read more >
prometheus - The Go Programming Language - GitHub Pages
With a custom registry, you are in control and decide yourself about the Collectors to register. HTTP Exposition. The Registry implements the Gatherer...
Read more >
Creating a Google Lighthouse custom audit that checks DOM ...
This article covers creating a Lighthouse custom audit and gatherer to perform checks against DOM elements.
Read more >
From Hunters And Gatherers To Farmers Worksheet | Cerritos ...
This worksheet was from hunters would you white man have trouble focusing or farmer. First, in restricting the transfer of ownership interests, ...
Read more >
Custom installation — pgwatch2 documentation - Read the Docs
For use cases where exposing the component (Grafana, Postgres, Influx, gatherer daemon, Web UI itself) logs over the “/logs” endpoint remotely is wanted,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found