Lighthouse: Extension Error: Failed to construct 'URL': Invalid URL

Created on 23 Dec 2016  路  20Comments  路  Source: GoogleChrome/lighthouse

Lighthouse Version: 1.3.1
Chrome Version: 55.0.2883.95
Error Message: Failed to construct 'URL': Invalid URL
Stack Trace:
TypeError: Failed to construct 'URL': Invalid URL at artifacts.DateNowUse.usage.filter.err (chrome-extension://blipmdconlkpinefehnmjammfjpmpbjk/scripts/lighthouse-background.js:1047:39) at Array.filter (native) at Function.audit (chrome-extension://blipmdconlkpinefehnmjammfjpmpbjk/scripts/lighthouse-background.js:1046:48) at Promise.resolve.then._ (chrome-extension://blipmdconlkpinefehnmjammfjpmpbjk/scripts/lighthouse-background.js:11388:20)

Most helpful comment

@elodszopos Can also confirm that disabling "Redux DevTools" extension resolve the issue.

All 20 comments

Earlier versions of lighthouse were working properly

Deactivated all plugins ... now it works! Trying to figure out which plugin causes the error ...

we also just pushed 1.3.2 with the fix from #1263, so that may also have helped

let us know if still broken

Okay, seems to be Redux DevTools 2.11.1.1 ... still using Lighthouse 1.3.1

Same error with Lighthouse 1.3.2 and Redux DevTools 2.11.1.1:

Lighthouse Version: 1.3.2
Chrome Version: 55.0.2883.95
Error Message: Failed to construct 'URL': Invalid URL
Stack Trace:
TypeError: Failed to construct 'URL': Invalid URL at artifacts.DateNowUse.usage.filter.err (chrome-extension://blipmdconlkpinefehnmjammfjpmpbjk/scripts/lighthouse-background.js:1054:24) at Array.filter (native) at Function.audit (chrome-extension://blipmdconlkpinefehnmjammfjpmpbjk/scripts/lighthouse-background.js:1050:48) at Promise.resolve.then._ (chrome-extension://blipmdconlkpinefehnmjammfjpmpbjk/scripts/lighthouse-background.js:11395:20)

And after click on Report Error button, I get:

Lighthouse Version: 1.3.2
Chrome Version: 55.0.2883.95
Error Message: You must provide a url to the driver
Stack Trace:
Error: You must provide a url to the driver at Function.run (chrome-extension://blipmdconlkpinefehnmjammfjpmpbjk/scripts/lighthouse-background.js:11251:29) at window.runLighthouseForConnection (chrome-extension://blipmdconlkpinefehnmjammfjpmpbjk/scripts/lighthouse-background.js:12218:17) at connection.getCurrentTabURL.then.url (chrome-extension://blipmdconlkpinefehnmjammfjpmpbjk/scripts/lighthouse-background.js:12231:25)

thanks, that's really helpful. We haven't gotten any good reproducible steps so far (or been able to see the errors ourselves), but Redux DevTools is a plausible lead on the volume of these errors we've gotten.

one interesting thing there is that's two different errors. I'm curious what that's about as well.

Happy to help! Thanks for taking care. <3 Lighthouse!

Installed the Redux extension and here's what we get as an URL:

screen shot 2016-12-23 at 2 11 13 pm

When there's no URL, we offer up https://github.com/GoogleChrome/lighthouse/blob/39cc6a7a47746baa700b5db6161a8d22627efa1b/lighthouse-core/gather/driver.js#L747 has context.

One way to be super careful we're not parsing weird URLs in the audits is to wrapnew URL() usage in try/catch. Not exactly sure that the extension is doing, but the <anonymous> url string is the same as what you get from devtools:

screen shot 2016-12-23 at 2 15 38 pm

I believe what's happening is that that redux extension has a content script that injects eval'd code that uses Date.now. It's all very hard to track down...compiled background pages from the Redux extension, injected callsite code from LH....

This is the script. After bundling, that file has a long string of code that presumably gets injected on the page. It uses Date.now:

screen shot 2016-12-23 at 2 52 56 pm

Ideally, all other chrome extensions would be disable when users run lighthouse. This is the case for the CLI. I'm not sure if the DT protocol or the extensions API has that capability :\

Here's the stacktrace from the violation:

screen shot 2016-12-23 at 3 01 31 pm

Hey folk - I'm also running into this issue. I also noticed a big spike of similar issues coming in from the automated way of issue opening directly from the extension. I also have strong reason to believe that redux chrome extension is our culprit - to confirm @ebidel's suspicions. Let me know if there's anything else that I can provide to help resolve this.

@elodszopos Can also confirm that disabling "Redux DevTools" extension resolve the issue.

Redux DevTools Extension creator here.

@ebidel, is there anything we can do from our side to solve these issues? As you noticed the script is injected as one string here into the script tag. When injected it as a separate file it has no issues with lighthouse. The reason for the first approach is that we need to load the extension's script before the client script (otherwise he wouldn't be able to apply Redux DevTools enhancer to the store). Date.now() comes from here and from lodash.

I can reproduce the issue by just using:

var s = document.createElement('script');
s.type = 'text/javascript';  
s.appendChild(document.createTextNode('var a = Date.now()'));
(document.head || document.documentElement).appendChild(s);
s.parentNode.removeChild(s);

UPDATE: Tried the build from #1288 and it fixes the issue.

@zalmoxisus, yea we'll have to protect against this in LH. Other popular extensions that inject content scripts will eventually hit the same issues.

@zalmoxisus Thanks. It is saving for me a lot of time 馃憤

@zalmoxisus Splendid open source community feels and collaboration. The world has a lot to learn from software folk. Thanks everyone!

Awesome 馃憤

Was this page helpful?
0 / 5 - 0 ratings