Skip to content
Advertisement

Node.js Lighthouse custom Gatherer/Audit – Protocol error (Runtime.evaluate): Object reference chain is too long

I am trying to implement custom audits using the lighthouse library lighthouse and executing some Javascript commands within the Gatherer I get the following error:

JavaScript

In detail I have the following Gatherer:

JavaScript

That with the expression defined above triggers the problem. There seems to be too much information and I can’t manage it. I’m testing the command on a web page and it returns 1059 collections (HTMLCollection(1059)).

When I run the lighthouse command to inspect a page, the warning is created and the result cannot be manipulated within the audit:

JavaScript

NB: In the lighthouse log i can see also this error:

JavaScript

I need to have a Gatherer that returns all HTMLCollection elements in order to compute them to get all the fonts on the page. How can I get around this problem?

Advertisement

Answer

There is already an artifact that collects all font information on a page: https://github.com/GoogleChrome/lighthouse/blob/master/types/artifacts.d.ts#L139

As for the actual error, you’d need to write a more complex function that you’d pass to evaluate to process the DOM and return only the data you want. If you write anything more than a single-line expression I suggest using driver.evaluate instead (see the Lighthouse repo for examples).

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement