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

DevTools Error: Failed to construct 'URL': Invalid URL #6145

Closed
santamaria7 opened this issue Sep 30, 2018 · 5 comments · Fixed by #6157
Closed

DevTools Error: Failed to construct 'URL': Invalid URL #6145

santamaria7 opened this issue Sep 30, 2018 · 5 comments · Fixed by #6157

Comments

@santamaria7
Copy link

Initial URL: https://www.bbc.com/sport
Chrome Version: 69.0.3497.100
Error Message: Failed to construct 'URL': Invalid URL
Stack Trace:

TypeError: Failed to construct 'URL': Invalid URL
    at new URLShim (chrome-devtools://devtools/remote/serve_file/@8920e690dd011895672947112477d10d5c8afb09/audits2_worker/audits2_worker_module.js:4878:1)
    at NetworkRequest.onRequestWillBeSent (chrome-devtools://devtools/remote/serve_file/@8920e690dd011895672947112477d10d5c8afb09/audits2_worker/audits2_worker_module.js:1405:67)
    at NetworkRecorder.onRequestWillBeSent (chrome-devtools://devtools/remote/serve_file/@8920e690dd011895672947112477d10d5c8afb09/audits2_worker/audits2_worker_module.js:1384:151)
    at NetworkRecorder.dispatch (chrome-devtools://devtools/remote/serve_file/@8920e690dd011895672947112477d10d5c8afb09/audits2_worker/audits2_worker_module.js:1394:66)
    at devtoolsLog.forEach.message (chrome-devtools://devtools/remote/serve_file/@8920e690dd011895672947112477d10d5c8afb09/audits2_worker/audits2_worker_module.js:1397:126)
    at Array.forEach (<anonymous>)
    at Function.recordsFromLogs (chrome-devtools://devtools/remote/serve_file/@8920e690dd011895672947112477d10d5c8afb09/audits2_worker/audits2_worker_module.js:1397:93)
    at Function.afterPass (chrome-devtools://devtools/remote/serve_file/@8920e690dd011895672947112477d10d5c8afb09/audits2_worker/audits2_worker_module.js:1087:163)
@patrickhulce
Copy link
Collaborator

Hm, I'm not able to reproduce this, but it clearly looks like others have (#6148). Are you still experiencing this @santamaria7 ?

@santamaria7
Copy link
Author

@patrickhulce Yes, I am. I ran the Audit on https://www.bbc.com/sport just now for another time and ran into this error again. Because of this, the Audit never finishes and I have to cancel it.

@exterkamp
Copy link
Member

Spent some time tracking this down thanks to @paulirish

TL;DR: We tracked down the root cause of this to mobile only audits from devtools audit panel. It is a result of the website's JS making malformed network requests that we do not catch. We have started look into handling these kinds of network requests.

This error seems to originate from BBC Sport itself, in their Javascript they have a feature detector searching for @font-face

...
if (!navigator.userAgent.match(/(Android (2.0|2.1))|(Nokia)|(Opera (Mini|Mobi))/)) {
                if (!navigator.userAgent.match(/(w(eb)?OSBrowser)|(UCWEB)|(Windows Phone OS 7)|(XBLWP)|(ZuneWP)/)) {
                    if (navigator.userAgent.match(/MSIE 10.0/))
                        return !0;
                    var t = document.getElementById("font-face-test")
                      , n = t.sheet || t.styleSheet
                      , r = "";
                    return n && (n.cssRules && n.cssRules[0] ? r = n.cssRules[0].cssText : r = n.cssText || ""),
                    /src/i.test(r) && r.indexOf("@font-face") === 0 ? !0 : !1
...
document.write('<style id="font-face-test">@font-face {font-family:"font";src:url("https://")}</style>'),
...

Which emits these network requests:
bbc_ font

The last one is searching for http:// as seen in the js src url above. This make a network request in the form:

{
    "method": "Network.requestWillBeSent",
    "params": {
      "requestId": "...",
      "loaderId": "...",
      "documentURL": "https://www.bbc.com/sport",
      "request": {
        "url": "https:",
        "method": "GET",
        "headers": {
          "Origin": "https://www.bbc.com"
        },
        "mixedContentType": "blockable",
        "initialPriority": "VeryLow",
        "referrerPolicy": "no-referrer-when-downgrade"
      },
      "timestamp": 831346.969485,
      "wallTime": 1538411434.25547,
      "initiator": {
        "type": "other"
      },
      "type": "Font",
      "frameId": "...",
      "hasUserGesture": false
    }
  },

This network request is processed in Lighthouse in network-request.js where the url 'https:' will result in a URL being marked as invalid:

onRequestWillBeSent(data) {
    this.requestId = data.requestId;

    const url = new URL(data.request.url);

@AlexWayfer
Copy link

AlexWayfer commented Jan 12, 2023

Still an error?

21:31:11.046 extensions.js:2550 Uncaught TypeError: Failed to construct 'URL': Invalid URL
    at ExtensionsErrorPageElement.onSelectedErrorChanged_ (extensions.js:2550:2882)
    at Object.ye [as fn] (polymer_bundled.min.js:1:26017)
    at pe (polymer_bundled.min.js:1:25548)
    at ExtensionsErrorPageElement._propertiesChanged (polymer_bundled.min.js:1:36783)
    at ExtensionsErrorPageElement._flushProperties (polymer_bundled.min.js:1:18163)
    at ExtensionsErrorPageElement._invalidateProperties (polymer_bundled.min.js:1:35745)
    at Object.defineProperty.set (polymer_bundled.min.js:1:16570)
    at ExtensionsErrorPageElement.observeDataChanges_ (extensions.js:2550:1748)
    at Object.ke [as fn] (polymer_bundled.min.js:1:31056)
    at pe (polymer_bundled.min.js:1:25548)
onSelectedErrorChanged_ @ extensions.js:2550
ye @ polymer_bundled.min.js:1
pe @ polymer_bundled.min.js:1
_propertiesChanged @ polymer_bundled.min.js:1
_flushProperties @ polymer_bundled.min.js:1
_invalidateProperties @ polymer_bundled.min.js:1
Object.defineProperty.set @ polymer_bundled.min.js:1
observeDataChanges_ @ extensions.js:2550
ke @ polymer_bundled.min.js:1
pe @ polymer_bundled.min.js:1

Version 109.0.5414.74 (Official Build) (64-bit)

I have empty "Errors" page for local extension.

It happens after 108.0.5359.124-1 -> 109.0.5414.74-1 update I believe .

@connorjclark
Copy link
Collaborator

connorjclark commented Jan 12, 2023

@AlexWayfer – thanks for the report, but 1) we need way more info, such as the URL this happens on + how you are running LH + what version + ... and 2) this needs to be a new issue, this one has been resolved for over 4 years now. New issue would have prompted for the info references in point 1)

Please continue in a new issue.

@GoogleChrome GoogleChrome locked as resolved and limited conversation to collaborators Jan 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants