-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Long attribute value truncation (PR #10984) fires off requests to the truncated URLs #11244
Comments
Thanks very much for the detailed bug report with examples @joshmcarthur! I can reproduce the behavior you describe. Perhaps it's time to convert outer HTML to operate on the stringified version rather than a live node, even if it is detached from the document. cc @Beytoven for his thoughts |
I have seen this issue on customer sites recently. Running Google PageSpeed against sites that have long resource URLs results in a large amount of 404s in rapid succession. Since WordPress handles 404s internally (via PHP) and those requests are not cached this causes a load spike. On sites with many long URLs and complex 404s it can even exhaust resources on hosting accounts (30+ 404s per second). Here is a sample access log from a test site: pastebin.com/mzmJqvMp I am afraid I am not able to provide suggestions for a fix but wanted to highlight the potential negative impact of the bug in production environments. |
Ah so we had someone dig more into this in #11465 and we have a proposed solution now. Even though this one is first, that issue has a better discussion history :) Thanks again for filing @joshmcarthur and for the extra info @asarosenberg! |
I submitted #11503 that fixes the issue.
|
Provide the steps to reproduce
src
attribute over 75 chraracters (just so it fails the largest contentful paint audit)python3 -m http.server
to run a HTTP server on localhost, port 8000.3, Audit the page:
lighthouse --only-categories=performance http://localhost:8000
There is a repo containing an image, an HTML file and a convenience bash script to audit at https://github.com/joshmcarthur/lighthouse-requesting-ellipsied-urls-repro.
HTTP server output:
What is the current behavior?
getOuterHTMLSnippet
truncates the attribute by cloning the attribute, setting the attribute with the truncated value, and then getting the attribute again. The specific issue is that some elements have a side effect of callingsetAttribute
- they request the attribute value. Tags that I know of with this behaviour areimg
andscript
, but I'm sure there are more. Because of this side effect,setAttribute
being called on the cloned element results in a request to the truncated URLs.This affects me specifically because I have a test run (RSpec/Capybara/Chromedriver) that runs Lighthouse as part of the CI process. Since updating to 6.2.0, the test suite fails, because any server-side failure is counted as a test suite failure - which is reasonable. When lighthouse runs, it tries to request a truncated URL for a webpack asset with a digest that pushes it over 75 chars, resulting in a server-side error being emitted due to the asset file being expected to be present (and it is - but not with a truncated filename).
What is the expected behavior?
In versions of Lighthouse prior to 6.2.0, image src attributes with a length greater than 75 chars would not be truncated, so the node would not be cloned, so the truncated URL would not be requested - thus, no malformed URLs were requested and our test suite was happy.
The frontend-facing truncation behaviour is correct, and appreciated. I'm unsure of an appropriate fix for this in the page functions, as I imagine the
clone
/setAttribute
/getAttribute
is being done for a good reason, and I'm not aware of a way to callsetAttribute
without triggering the effects of setting that attribute.Environment Information
NAME="Pop!_OS"
VERSION="20.04 LTS"
ID=pop
ID_LIKE="ubuntu debian"
PRETTY_NAME="Pop!_OS 20.04 LTS"
VERSION_ID="20.04"
HOME_URL="https://pop.system76.com"
SUPPORT_URL="https://support.system76.com"
BUG_REPORT_URL="https://github.com/pop-os/pop/issues"
PRIVACY_POLICY_URL="https://system76.com/privacy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
LOGO=distributor-logo-pop-os
Related issues
[ No bug reports found in search for: Recent, "truncated", "ellipsis", "truncating", "truncate" ]
The text was updated successfully, but these errors were encountered: