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

PPTR Request blocking halts LH #14985

Closed
2 tasks done
benschwarz opened this issue Apr 18, 2023 · 4 comments · Fixed by #15000
Closed
2 tasks done

PPTR Request blocking halts LH #14985

benschwarz opened this issue Apr 18, 2023 · 4 comments · Fixed by #15000
Assignees

Comments

@benschwarz
Copy link
Contributor

FAQ

URL

https://bonappetit.com

What happened?

Scenario

  • Ran LH in Node, using an adapted version of the Puppeteer example
  • Puppeteer used to intercept and block requests
  • When a request is blocked, LH halts and eventually completes the test after 2 min 29 seconds
  • Test completed, with errors:
"runtimeError": {
  "code": "PROTOCOL_TIMEOUT",
  "message": "Waiting for DevTools protocol response has exceeded the allotted time. (Method: CSS.enable)"
}

Script used to repro:

import puppeteer from 'puppeteer'
import lighthouse from 'lighthouse'
import { writeFile } from 'node:fs'

const url = 'https://chromestatus.com/features'
const URLS_TO_BLOCK = ['https://www.google-analytics.com/analytics.js']

// Use Puppeteer to launch headful Chrome and don't use its default 800x600 viewport.
const browser = await puppeteer.launch({
  headless: false,
  defaultViewport: null,
  ignoreDefaultArgs: ['--enable-automation']
})
const page = await browser.newPage()

// Intercept request and block.
// See https://pptr.dev/guides/request-interception for reference
await page.setRequestInterception(true)
page.on('request', request => {
  if (request.isInterceptResolutionHandled()) return

  const requestURL = request.url()

  const requestShouldBeBlocked = URLS_TO_BLOCK.includes(requestURL)

  if (requestShouldBeBlocked) {
    console.log(`Blocked request to ${requestURL}`)
    request.abort()
  } else {
    request.continue()
  }
})

// Lighthouse will open the URL.
const { lhr } = await lighthouse(url, undefined, undefined, page)

const data = new Uint8Array(Buffer.from(JSON.stringify(lhr)))
writeFile('lhr.json', data, err => {
  if (err) throw err
})

console.log(
  `Lighthouse scores: ${Object.values(lhr.categories)
    .map(c => c.score)
    .join(', ')}`
)

await browser.close()

What did you expect?

Expected Lighthouse to complete successfully.

What have you tried?

Nothing else yet!

How were you running Lighthouse?

node

Lighthouse Version

10.1.0

Chrome Version

112.0.5615.49

Node Version

18.7.X

OS

Mac

Relevant log output

LH:status Connecting to browser +0ms
  LH:status Navigating to about:blank +9ms
  LH:status Benchmarking machine +9ms
  LH:status Preparing target for navigation mode +1s
  LH:status Navigating to about:blank +16ms
  LH:status Preparing target for navigation +12ms
  LH:status Cleaning origin data +100ms
  LH:status Cleaning browser cache +6ms
  LH:status Preparing network conditions +2s
  LH:status Navigating to https://chromestatus.com/features +92ms
Blocked request to https://www.google-analytics.com/analytics.js
  LH:artifacts:getArtifact DevtoolsLog +9s
  LH:artifacts:getArtifact Trace +0ms
  LH:artifacts:getArtifact DevtoolsLog +2ms
  LH:artifacts:getArtifact Trace +0ms
  LH:artifacts:getArtifact Accessibility +0ms
  LH:artifacts:getArtifact AnchorElements +5s
  LH:artifacts:getArtifact ConsoleMessages +2s
  LH:artifacts:getArtifact CSSUsage +0ms
  LH:artifacts:getArtifact Doctype +30s
  LH:artifacts:getArtifact DOMStats +3ms
  LH:artifacts:getArtifact EmbeddedContent +34ms
  LH:artifacts:getArtifact FontSize +25ms
  LH:artifacts:getArtifact Inputs +30s
  LH:artifacts:getArtifact GlobalListeners +75ms
  LH:artifacts:getArtifact ImageElements +44ms
  LH:artifacts:getArtifact InstallabilityErrors +30s
  LH:status Get webapp installability errors +1ms
  LH:artifacts:getArtifact InspectorIssues +1ms
  LH:artifacts:getArtifact JsUsage +1ms
  LH:artifacts:getArtifact LinkElements +0ms
  LH:artifacts:getArtifact MainDocumentContent +29ms
  LH:artifacts:getArtifact MetaElements +4ms
  LH:artifacts:getArtifact NetworkUserAgent +27ms
  LH:artifacts:getArtifact OptimizedImages +0ms
  LH:artifacts:getArtifact ResponseCompression +1ms
  LH:artifacts:getArtifact RobotsTxt +5ms
  LH:artifacts:getArtifact ServiceWorker +356ms
  LH:artifacts:getArtifact Scripts +9ms
  LH:artifacts:getArtifact SourceMaps +0ms
  LH:artifacts:getArtifact Stacks +2s
  LH:status Collect stacks +1ms
  LH:artifacts:getArtifact TagsBlockingFirstPaint +29ms
  LH:artifacts:getArtifact TapTargets +3ms
  LH:artifacts:getArtifact TraceElements +30s
  LH:artifacts:getArtifact ViewportDimensions +108ms
  LH:artifacts:getArtifact WebAppManifest +1ms
  LH:status Get webapp manifest +1ms
  LH:artifacts:getArtifact devtoolsLogs +1ms
  LH:artifacts:getArtifact traces +0ms
  LH:artifacts:getArtifact FullPageScreenshot +0ms
  LH:artifacts:getArtifact BFCacheFailures +6s
  LH:CSSUsage:warn Error fetching content of stylesheet with URL "https://chromestatus.com/static/css/features/features.css?v=4dda7c5" +667ms
  LH:CSSUsage:warn Error fetching content of stylesheet with URL "https://chromestatus.com/static/css/base.css?v=4dda7c5" +0ms
  LH:CSSUsage:warn Error fetching content of stylesheet with URL "https://chromestatus.com/static/css/main.css?v=4dda7c5" +0ms
  LH:CSSUsage:warn Error fetching content of stylesheet with URL "https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" +1ms
  LH:status Analyzing and running audits... +4ms
  LH:status Auditing: Uses HTTPS +1ms
  LH:status Auditing: Registers a service worker that controls page and `start_url` +2ms
  LH:status Auditing: Has a `<meta name="viewport">` tag with `width` or `initial-scale` +0ms
  LH:status Auditing: First Contentful Paint +2ms
  LH:status Auditing: Largest Contentful Paint +107ms
  LH:status Auditing: First Meaningful Paint +28ms
  LH:status Auditing: Speed Index +6ms
  LH:status Auditing: Screenshot Thumbnails +489ms
  LH:status Auditing: Final Screenshot +0ms
  LH:status Auditing: Total Blocking Time +3ms
  LH:status Auditing: Max Potential First Input Delay +18ms
  LH:status Auditing: Cumulative Layout Shift +15ms
  LH:status Auditing: No browser errors logged to the console +5ms
  LH:status Auditing: Initial server response time was short +1ms
  LH:status Auditing: Time to Interactive +1ms
  LH:status Auditing: User Timing marks and measures +1ms
  LH:status Auditing: Avoid chaining critical requests +11ms
  LH:status Auditing: Avoid multiple page redirects +4ms
  LH:status Auditing: Web app manifest and service worker meet the installability requirements +7ms
  LH:status Auditing: Configured for a custom splash screen +1ms
  LH:status Auditing: Sets a theme color for the address bar. +1ms
  LH:status Auditing: Manifest has a maskable icon +0ms
  LH:status Auditing: Content is sized correctly for the viewport +0ms
  LH:status Auditing: Displays images with correct aspect ratio +0ms
  LH:Runner:warn ImageElements gatherer, required by audit image-aspect-ratio, encountered an error: PROTOCOL_TIMEOUT +1ms
  LH:status Auditing: Serves images with appropriate resolution +0ms
  LH:Runner:warn ImageElements gatherer, required by audit image-size-responsive, encountered an error: PROTOCOL_TIMEOUT +0ms
  LH:status Auditing: Fonts with `font-display: optional` are preloaded +0ms
  LH:Runner:warn CSSUsage gatherer, required by audit preload-fonts, encountered an error: PROTOCOL_TIMEOUT +0ms
  LH:status Auditing: Avoids deprecated APIs +1ms
  LH:status Auditing: Minimizes main-thread work +0ms
  LH:status Auditing: JavaScript execution time +101ms
  LH:status Auditing: Preload key requests +10ms
  LH:status Auditing: Preconnect to required origins +0ms
  LH:status Auditing: All text remains visible during webfont loads +2ms
  LH:Runner:warn CSSUsage gatherer, required by audit font-display, encountered an error: PROTOCOL_TIMEOUT +0ms
  LH:status Auditing: Diagnostics +1ms
  LH:status Auditing: Network Requests +1ms
  LH:status Auditing: Network Round Trip Times +8ms
  LH:status Auditing: Server Backend Latencies +1ms
  LH:status Auditing: Tasks +1ms
  LH:status Auditing: Metrics +2ms
  LH:status Auditing: Performance budget +2ms
  LH:status Auditing: Timing budget +2ms
  LH:status Auditing: Keep request counts low and transfer sizes small +0ms
  LH:status Auditing: Minimize third-party usage +1ms
  LH:status Auditing: Lazy load third-party resources with facades +14ms
  LH:status Auditing: Largest Contentful Paint element +23ms
  LH:status Auditing: Largest Contentful Paint image was not lazily loaded +0ms
  LH:Runner:warn ImageElements gatherer, required by audit lcp-lazy-loaded, encountered an error: PROTOCOL_TIMEOUT +0ms
  LH:status Auditing: Avoid large layout shifts +1ms
  LH:status Auditing: Avoid long main-thread tasks +0ms
  LH:status Auditing: Avoids `unload` event listeners +8ms
  LH:status Auditing: Avoid non-composited animations +1ms
  LH:status Auditing: Image elements have explicit `width` and `height` +0ms
  LH:Runner:warn ImageElements gatherer, required by audit unsized-images, encountered an error: PROTOCOL_TIMEOUT +0ms
  LH:status Auditing: Page has valid source maps +0ms
  LH:status Auditing: Preload Largest Contentful Paint image +1ms
  LH:status Auditing: Ensure CSP is effective against XSS attacks +0ms
  LH:status Auditing: Script Treemap Data +4ms
  LH:status Auditing: Site works cross-browser +21ms
  LH:status Auditing: Page transitions don't feel like they block on the network +0ms
  LH:status Auditing: Each page has a URL +0ms
  LH:status Auditing: `[accesskey]` values are unique +0ms
  LH:status Auditing: `[aria-*]` attributes match their roles +0ms
  LH:status Auditing: `button`, `link`, and `menuitem` elements have accessible names +0ms
  LH:status Auditing: `[aria-hidden="true"]` is not present on the document `<body>` +0ms
  LH:status Auditing: `[aria-hidden="true"]` elements do not contain focusable descendents +1ms
  LH:status Auditing: ARIA input fields have accessible names +0ms
  LH:status Auditing: ARIA `meter` elements have accessible names +0ms
  LH:status Auditing: ARIA `progressbar` elements have accessible names +1ms
  LH:status Auditing: `[role]`s have all required `[aria-*]` attributes +0ms
  LH:status Auditing: Elements with an ARIA `[role]` that require children to contain a specific `[role]` have all required children. +0ms
  LH:status Auditing: `[role]`s are contained by their required parent element +0ms
  LH:status Auditing: `[role]` values are valid +0ms
  LH:status Auditing: ARIA toggle fields have accessible names +0ms
  LH:status Auditing: ARIA `tooltip` elements have accessible names +1ms
  LH:status Auditing: ARIA `treeitem` elements have accessible names +0ms
  LH:status Auditing: `[aria-*]` attributes have valid values +0ms
  LH:status Auditing: `[aria-*]` attributes are valid and not misspelled +0ms
  LH:status Auditing: Buttons have an accessible name +0ms
  LH:status Auditing: The page contains a heading, skip link, or landmark region +1ms
  LH:status Auditing: Background and foreground colors have a sufficient contrast ratio +0ms
  LH:status Auditing: `<dl>`'s contain only properly-ordered `<dt>` and `<dd>` groups, `<script>`, `<template>` or `<div>` elements. +1ms
  LH:status Auditing: Definition list items are wrapped in `<dl>` elements +0ms
  LH:status Auditing: Document has a `<title>` element +0ms
  LH:status Auditing: `[id]` attributes on active, focusable elements are unique +1ms
  LH:status Auditing: ARIA IDs are unique +0ms
  LH:status Auditing: No form fields have multiple labels +0ms
  LH:status Auditing: `<frame>` or `<iframe>` elements have a title +0ms
  LH:status Auditing: Heading elements appear in a sequentially-descending order +1ms
  LH:status Auditing: `<html>` element has a `[lang]` attribute +0ms
  LH:status Auditing: `<html>` element has a valid value for its `[lang]` attribute +0ms
  LH:status Auditing: Image elements have `[alt]` attributes +0ms
  LH:status Auditing: `<input type="image">` elements have `[alt]` text +1ms
  LH:status Auditing: Form elements have associated labels +0ms
  LH:status Auditing: Links have a discernible name +0ms
  LH:status Auditing: Lists contain only `<li>` elements and script supporting elements (`<script>` and `<template>`). +1ms
  LH:status Auditing: List items (`<li>`) are contained within `<ul>`, `<ol>` or `<menu>` parent elements +0ms
  LH:status Auditing: The document does not use `<meta http-equiv="refresh">` +1ms
  LH:status Auditing: `[user-scalable="no"]` is not used in the `<meta name="viewport">` element and the `[maximum-scale]` attribute is not less than 5. +0ms
  LH:status Auditing: `<object>` elements have alternate text +0ms
  LH:status Auditing: No element has a `[tabindex]` value greater than 0 +0ms
  LH:status Auditing: Cells in a `<table>` element that use the `[headers]` attribute refer to table cells within the same table. +0ms
  LH:status Auditing: `<th>` elements and elements with `[role="columnheader"/"rowheader"]` have data cells they describe. +1ms
  LH:status Auditing: `[lang]` attributes have a valid value +0ms
  LH:status Auditing: `<video>` elements contain a `<track>` element with `[kind="captions"]` +0ms
  LH:status Auditing: Custom controls have associated labels +0ms
  LH:status Auditing: Custom controls have ARIA roles +0ms
  LH:status Auditing: User focus is not accidentally trapped in a region +0ms
  LH:status Auditing: Interactive controls are keyboard focusable +0ms
  LH:status Auditing: Interactive elements indicate their purpose and state +0ms
  LH:status Auditing: The page has a logical tab order +0ms
  LH:status Auditing: The user's focus is directed to new content added to the page +0ms
  LH:status Auditing: Offscreen content is hidden from assistive technology +0ms
  LH:status Auditing: HTML5 landmark elements are used to improve navigation +0ms
  LH:status Auditing: Visual order on the page follows DOM order +0ms
  LH:status Auditing: Uses efficient cache policy on static assets +1ms
  LH:status Auditing: Avoids enormous network payloads +5ms
  LH:status Auditing: Defer offscreen images +1ms
  LH:Runner:warn ImageElements gatherer, required by audit offscreen-images, encountered an error: PROTOCOL_TIMEOUT +0ms
  LH:status Auditing: Eliminate render-blocking resources +1ms
  LH:Runner:warn CSSUsage gatherer, required by audit render-blocking-resources, encountered an error: PROTOCOL_TIMEOUT +0ms
  LH:status Auditing: Minify CSS +0ms
  LH:Runner:warn CSSUsage gatherer, required by audit unminified-css, encountered an error: PROTOCOL_TIMEOUT +0ms
  LH:status Auditing: Minify JavaScript +0ms
  LH:status Auditing: Reduce unused CSS +101ms
  LH:Runner:warn CSSUsage gatherer, required by audit unused-css-rules, encountered an error: PROTOCOL_TIMEOUT +0ms
  LH:status Auditing: Reduce unused JavaScript +0ms
  LH:status Auditing: Serve images in next-gen formats +9ms
  LH:Runner:warn ImageElements gatherer, required by audit modern-image-formats, encountered an error: PROTOCOL_TIMEOUT +1ms
  LH:status Auditing: Efficiently encode images +0ms
  LH:Runner:warn ImageElements gatherer, required by audit uses-optimized-images, encountered an error: PROTOCOL_TIMEOUT +0ms
  LH:status Auditing: Enable text compression +0ms
  LH:status Auditing: Properly size images +15ms
  LH:Runner:warn ImageElements gatherer, required by audit uses-responsive-images, encountered an error: PROTOCOL_TIMEOUT +0ms
  LH:status Auditing: Use video formats for animated content +0ms
  LH:status Auditing: Remove duplicate modules in JavaScript bundles +15ms
  LH:status Auditing: Avoid serving legacy JavaScript to modern browsers +15ms
  LH:status Auditing: Page has the HTML doctype +50ms
  LH:status Auditing: Properly defines charset +0ms
  LH:status Auditing: Avoids an excessive DOM size +1ms
  LH:status Auditing: Avoids requesting the geolocation permission on page load +0ms
  LH:status Auditing: No issues in the `Issues` panel in Chrome Devtools +1ms
  LH:status Auditing: Avoids `document.write()` +0ms
  LH:status Auditing: Detected JavaScript libraries +0ms
  LH:status Auditing: Avoids requesting the notification permission on page load +1ms
  LH:status Auditing: Allows users to paste into input fields +0ms
  LH:status Auditing: Use HTTP/2 +0ms
  LH:status Auditing: Uses passive listeners to improve scrolling performance +13ms
  LH:status Auditing: Document has a meta description +0ms
  LH:status Auditing: Page has successful HTTP status code +0ms
  LH:status Auditing: Document uses legible font sizes +0ms
  LH:Runner:warn FontSize gatherer, required by audit font-size, encountered an error: PROTOCOL_TIMEOUT +1ms
  LH:status Auditing: Links have descriptive text +0ms
  LH:status Auditing: Links are crawlable +19ms
  LH:status Auditing: Page isn’t blocked from indexing +19ms
  LH:status Auditing: robots.txt is valid +2ms
  LH:status Auditing: Tap targets are sized appropriately +1ms
  LH:Runner:warn TapTargets gatherer, required by audit tap-targets, encountered an error: PROTOCOL_TIMEOUT +0ms
  LH:status Auditing: Document has a valid `hreflang` +0ms
  LH:status Auditing: Document avoids plugins +0ms
  LH:status Auditing: Document has a valid `rel=canonical` +0ms
  LH:status Auditing: Structured data is valid +0ms
  LH:status Auditing: Page didn't prevent back/forward cache restoration +1ms
  LH:status Generating results... +0ms
Lighthouse scores: 0.14, 0.77, , , 0.33
@adamraine
Copy link
Member

I was able to reproduce without Lighthouse and filed upstream:
puppeteer/puppeteer#10041

@benschwarz
Copy link
Contributor Author

@adamraine ah thanks, I didn't think to prepare a stand-alone pptr repro 🫶

@adamraine
Copy link
Member

This was fixed if you update pptr on your end. I will update our pptr deps for good measure.

@benschwarz
Copy link
Contributor Author

That appears to have resolved the halting issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants