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

Custom gatherer not executed #16351

Open
chriswdmr opened this issue Feb 24, 2025 · 4 comments
Open

Custom gatherer not executed #16351

chriswdmr opened this issue Feb 24, 2025 · 4 comments

Comments

@chriswdmr
Copy link

chriswdmr commented Feb 24, 2025

Hey there,

I'm trying to create a custom gatherer that is executed when Lighthouse is running.

I have the following setup:

const chrome = await launch({
  chromeFlags: ["--headless"],
});

const result = await lighthouse(
  "https://www.example.com",
  {
    port: chrome.port,
    logLevel: "warn",
    output: "json",
  },
  {
    extends: "lighthouse:default",
    artifacts: [
      {
        id: "my-artifact",
        gatherer: "./custom-gatherer.js",
      },
    ]
  }

I see that the gatherer file is loaded but not executed.
As soon as I remove the extends: "lighthouse:default", it's running.

Is this intended?

Another thing I noticed:
Even if I load the full config (instead of just doing extends: "lighthouse:default"), it's not running. The only way I made it work was to create a fake audit with a fake category, only then, the gatherer was running.

Appreciate any points or insights, it would be great to avoid the fake audit/category!

@connorjclark
Copy link
Collaborator

Gathers get filtered out based on the needs of the requested audits. There isn't a way to configure that, though we do have a hardcoded list of special artifacts that ignore this filtering here.

Avoiding this filtering was asked about once.

You may have seen this already, but here's an example that should work today (though it uses the hidden audit trick). One thing I'll add is that you can assign the auditRef to the hidden group to totally hide it within the report renderer.

I didn't look into the oddity you mentioned about the extends property - maybe someone else can jump in there.

@connorjclark
Copy link
Collaborator

@adamraine helped figure this out - we skip the filtering if there are no audits defined in the config. Unsure if this was intentional or not, but there ya go.

@chriswdmr
Copy link
Author

though it uses the hidden audit trick

Could you elaborate on this? The config looks quite normal, what's the trick?

I didn't look into the oddity you mentioned about the extends property - maybe someone else can jump in there.

So it should work as I mentioned above?

@connorjclark
Copy link
Collaborator

Could you elaborate on this? The config looks quite normal, what's the trick?

I'm referring to making an otherwise useless audit to ensure a gatherer runs ("a fake audit with a fake category").

So it should work as I mentioned above?

As I alluded to here, the presence of "extends" inserts an "audits" property to the config. Without the "audits" property, the logic that filters out gatherers is skipped. This likely was not intentional, as we've always intended to strip out gatherers not utilized by any requested audit.

in summary..

Is this intended?

  1. Filtering out unused gatherers/artifact is intended
  2. That the filtering doesn't happen when providing no "extends" or "audits" property in a custom config is likely not intended

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