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.

RFC: Allow passing in of a existing page debugger URL to lighthouse

See original GitHub issue

Feature request summary

Having Chrome running in a different environment (for instance, on a cloud provider accessible via a pathed URL, eg “https://my-site.com/path/to/chrome/page”) makes it hard to have remote lighthouse access it, since there’s more than just host and port that it needs to know in order to connect. It’d also be useful to have a page in a prior-state passed into lighthouse for getting metrics as well (IE: a page generated by puppeteer, that’s clicked a few things and navigated and is now ready for lighthouse stats).

Because of the above, it’d be fantastic if a raw page-debugger URL could be provided into the main lighthouse interface vs just host and port.

How is this beneficial to Ligthhouse?

This would allow lighthouse to be used in more cases, and connect into an existing page so that more nuanced stats can be retrieved for a given page in a particular state.

Are you willing to work on this yourself?

As for the work, I’d definitely be interested in doing this work myself as I have it patched locally to run this behavior. Here’s a small snippet of how I’m doing it right now (warning I’m over-writing methods and pulling in internals!):

const Connection = require('lighthouse/lighthouse-core/gather/connections/cri');
const Config = require('lighthouse/lighthouse-core/config/config');
const Runner = require('lighthouse/lighthouse-core/runner');

const webSocketDebuggerUrl = 'wss://some-remote-host.com/devtools/page/abc-123';

const connection = new Connection();
const config = new Config();

// Overwrite connect/disconnect to provide a pre-generated page
connection.connect = function wrappedConnect() {
  return connection._connectToSocket({ webSocketDebuggerUrl });
};

connection.disconnect = function wrappedDisconnect() {
  if (this._ws) {
    this._ws.removeAllListeners();
    this._ws.close();
    this._ws = null;
  }
  return Promise.resolve();
};

// Run stats on example.com
Runner.run(connection, {
  url: 'https://example.com',
  config,
})
  .then((res) => console.log(res))
  .catch((error) => console.error(error));

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
paulirishcommented, Nov 29, 2018

A PR sounds great.

It seems like the idea is we add a new arg to lighthouse-core/index’s entry of webSocketDebuggerUrl and if that’s present, then we’ll create a new connection based off that (we’ll need a new connection subclass that has an empty connect() method, etc).

Based on the code you already wrote above, it seems like you got this under control. 😃

Let’s do it.

0reactions
patrickhulcecommented, Sep 20, 2021

That report comes from using await lighthouse(url, flags, configJson, userConnection) method in lighthouse-core/index.js

No, it doesn’t. Did you share the incorrect screenshot?

We have already provided all of the necessary steps, this provides the Lighthouse HTML report of an existing tab using the snapshot API.

const puppeteer = require('puppeteer')
const lighthouse = require('lighthouse/lighthouse-core/fraggle-rock/api.js')
const open = require('open')
const fs = require('fs')

async function main() {
  const browser = await puppeteer.launch()
  const page = await browser.newPage()
  await page.goto('https://example.com')
  const result = await lighthouse.snapshot({
    page,
    configContext: {
      settingsOverrides: {output: 'html'}
    },
  })

  fs.writeFileSync('report.html', result.report)
  open('report.html')
}

main()
Read more comments on GitHub >

github_iconTop Results From Across the Web

Lighthouse User Guide - of /download
After validation passes, click Create. 17. Go to the Virtual Machines page, select the virtual machine and open the Serial Console. Lighthouse.
Read more >
Lighthouse overview - Chrome Developers
You give Lighthouse a URL to audit, it runs a series of audits against the page, and then it generates a report on...
Read more >
sip - River Thames Conditions - Environment Agency - GOV.UK
Style diva hair facebook, Billy idol 2014 tour dates, Letter e colouring pages, Mapquest powell tn, Liquida dourados setembro, Audi a5 2016 interior, ......
Read more >
Blog | DebugBear
Lab-based performance tests often give different results from data that's collected from real users. This article explains the differences between these two ...
Read more >
An Introduction To Running Lighthouse Programmatically
This article contains a brief introduction to Lighthouse, discusses the advantages of running it programmatically, and walks through a basic ...
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