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.

Incorrect main document used when retrieving page load errors

See original GitHub issue

Provide the steps to reproduce

  1. Run LH programmatically on page that redirects a similarly matching URL (e.g. same startsWith(request.url)), where the redirect response does not return text/html as its mime type.

More Information

I’m not sure how common this for non-authenticated redirects, but in our case we are running LH on authenticated pages using cookie-based login (similar to this doc, but with Node API).

The redirect response when hitting the requestedUrl (prior to auth) does not return HTML, and so the content-type response header is empty. It then redirects to the authentication server, and finally back to the originally requested document this time with the correct mime type text/html.

What is the current behavior?

LH reports error NOT_HTML even though document loaded in the final URL after redirecting is text/html.

I don’t see any documentation on this, but according @brendankenny in #11430, it should be the final matching URL (that is an html document) when loading the page.

The error occurred starting in version 6.2.0 of LH from #11042.

I have a fix locally by using the last matching HTML document (as opposed to the first) in findMainDocument(records, finalURL).

A naive one-line fix that works on my site in test is:

// should probably search backwards using loop
const mainResource = records.slice().reverse().find(request => finalURL.startsWith(request.url) &&
        URL.equalWithExcludedFragments(request.url, finalURL));

As for the logic when finalUrl is not supplied, I think the comment on line 452 still applies.

What is the expected behavior?

LH doesn’t fail when valid redirect eventually responds with HTML on a matching finalUrl.

Environment Information

  • Affected Channels: Node
  • Lighthouse version: >=6.2.0
  • Chrome version: N/A
  • Node.js version: 12.9.2
  • Operating System: MacOS (and Docker Linux Container)

Related issues

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
bradfrostycommented, Oct 30, 2020

Hey @patrickhulce, I should have a PR up soon. All good from my end to contribute and CLA has been signed.

0reactions
bradfrostycommented, Oct 27, 2020

@patrickhulce sorry for the delay. Figuring out the legal approval on my end before signing the CLA and submitting a contribution 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved: How to fix : There was an error processing a page....
Hi amya61582079,. The issue is probably because there are special characters hidden in the file. That said, it is still the issue with...
Read more >
Common PDF File Errors and Solution to Resolve
The 404 Page Loading Error is usually observed when the PDF file is either removed or moved leaving the URL unchanged.
Read more >
Fix "Aw, Snap!" page crashes and other page loading errors
If you receive a page loading error: To correct the problem, follow the steps below. You can begin by reloading the page. Android...
Read more >
How to troubleshoot damaged documents in Word - Office
Repeatedly renumbers the existing pages in the document; Repeatedly redoes the page breaks in the document; Incorrect document layout and ...
Read more >
How to Solve the Chunk Load Error in JavaScript - Rollbar
Whenever there's an error observed in dynamically fetching helper JavaScript files known as Chunks, a ChunkLoad Error is thrown.
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