Skip to content

lighthouse_audit summary prints category scores with floating-point noise #2916

Closed

Description

@coygeek

Description of the bug

The text summary returned by lighthouse_audit prints a fractional category score with floating-point noise, for example Accessibility: 56.99999999999999 for the score 0.57 that Lighthouse writes to report.json and displays as 57. The value is off by about 1e-14, so the reader still gets the right magnitude, but the summary no longer matches the score Lighthouse reports. Observed in navigation and snapshot modes on 1.10.1 and on main at b2f522c. Lighthouse rounds category scores to two decimals, and 8 of the 101 possible values print with noise in Node because multiplying them by 100 in floating point is not exact: 0.07, 0.14, 0.28, 0.29, 0.55, 0.56, 0.57 and 0.58.

Actual behavior

On main in navigation mode, the relevant category lines were (the run also printed an Agentic Browsing line, which belongs to the separate null-score issue):

### Category Scores
- Accessibility: 56.99999999999999 (accessibility)
- Best Practices: 96 (best-practices)
- SEO: 82 (seo)

The report.json from the same call had "accessibility": 0.57, "best-practices": 0.96 and "seo": 0.82. 1.10.1 printed the same lines. Both versions printed Accessibility: 56.99999999999999 in snapshot mode too, against the same report.json value of 0.57.

Run counts: across 15 local MCP sessions on this page (both versions, navigation and snapshot in each), all 30 audits printed Accessibility: 56.99999999999999 while report.json held 0.57. 4 of those sessions used the fixture above exactly; the rest used equivalent pages with the same markup apart from the inline script, and different /llms.txt responses.

A control page whose Accessibility score was 0.33 printed 33 on both versions, because 0.33 * 100 happens to be exact. The noise depends on the score value, not on the page or the mode.

Reproduction

  1. Save this loopback fixture as /tmp/x/server.mjs and run node /tmp/x/server.mjs; it prints its port (PORT below). The default page gets an Accessibility score of 0.57. The /llms.txt and control branches belong to the separate null-score issue and do not affect this one:
import http from 'node:http';
const control = process.argv[2] === 'control';
const png = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg==', 'base64');
const server = http.createServer((req, res) => {
  const {port} = server.address();
  if (req.url === '/') {
    res.writeHead(200, {'content-type': 'text/html'});
    return res.end(control
      ? '<!doctype html><html><head><title>Control</title></head><body><h1>Control</h1><img src="pixel.png"><button></button><a href="#"></a><input type="text"></body></html>'
      : `<!doctype html><title>Fixture</title><h1>Fixture</h1><img src="http://localhost:${port}/pixel.png"><script>fetch('/data.json')</script>`);
  }
  if (req.url === '/pixel.png') { res.writeHead(200, {'content-type': 'image/png'}); return res.end(png); }
  if (req.url === '/data.json') { res.writeHead(200, {'content-type': 'application/json'}); return res.end('{"ok":true}'); }
  if (req.url === '/llms.txt' && !control) { res.writeHead(304); return res.end(); }
  res.writeHead(404); res.end();
});
server.listen(0, '127.0.0.1', () => console.log(server.address().port));
  1. Start the MCP server over stdio with any MCP client: npx -y chrome-devtools-mcp@1.10.1 --isolated --headless --no-usage-statistics --no-performance-crux. For main, run npm ci && npm run build in a checkout, then node build/src/bin/chrome-devtools-mcp.js with the same flags; that build still reports version 1.10.1 because the version bump happens at release.
  2. Call new_page with {"url": "http://127.0.0.1:PORT/"}.
  3. Call lighthouse_audit with {"pageId": <the new page id>, "mode": "navigation", "device": "desktop"}, then again with "mode": "snapshot".
  4. Compare the Accessibility line under ### Category Scores with categories.accessibility.score in the report.json file listed in the same result.

Tested environment: macOS, Node v24.21.0, Google Chrome 154.0.8037.93, bundled Lighthouse 13.4.1 (the lighthouseVersion in report.json). The arithmetic alone is enough to show the effect: in Node, 0.57 * 100 evaluates to 56.99999999999999.

Expectation

The summary reports category scores on Lighthouse's 0-100 scale as Lighthouse presents them:

  • Lighthouse's report renders a category score as Math.round(score * 100) (report/renderer/category-renderer.js:385, lighthouse 13.5.0).
  • The tool description promises "Lighthouse score and reports" (src/tools/lighthouse.ts:36, and docs/tool-reference.md:425 on main).

For this fixture, Accessibility should be shown as 57.

Chrome DevTools MCP version

1.10.1 (npm) and main b2f522c (local build)

Chrome version

154.0.8037.93 (stable, headless, isolated)

Node version

v24.21.0

Operating system

macOS

Evidence

  • Expected source: Lighthouse's display rule Math.round(numericScore * 100) at report/renderer/category-renderer.js:385 (lighthouse 13.5.0 npm package); the tool description at src/tools/lighthouse.ts:36 (main and tag chrome-devtools-mcp-v1.10.1).
  • Failure source: local MCP runs on 1.10.1 and main, comparing the lighthouse_audit text result with the report.json written by the same call. The score line is built as (score.score ?? 0) * 100 with no rounding at src/McpResponse.ts:1162-1164 on main and src/McpResponse.ts:1116-1120 at tag chrome-devtools-mcp-v1.10.1.
  • Evidence provenance: observed
  • Local verification: reproduced
  • Reproduction completeness: complete

Additional context

A separate issue, #2915, covers the same summary line printing a null category score as 0. That defect is reported separately because either one can be fixed while the other remains, and they rest on different contracts: Lighthouse's display rounding here, Lighthouse's null-score semantics there.

Total Timing is out of scope. Its printed value matched report.json exactly in every run, including noisy values such as 7940.650000000001 and 3973.0499999999997. Lighthouse itself stores timing.total as the sum of two rounded durations, and no project or Lighthouse source promises a rounded timing.

Fix check

Run the fixture above on the fixed build in both modes.

  • Failing today: Accessibility: 56.99999999999999 while report.json holds 0.57.
  • Restored: the Accessibility line shows 57, Lighthouse's rounded value, with no floating-point artifact.

Controls:

  • Scores that already print exactly keep their values: 0.96 as 96, 0.82 as 82, 1 as 100, and the control page's 0.33 as 33.
  • With --experimentalStructuredContent, the structured scores still carry the raw 0.57.

Activity

  1. yulunz commented on Oct 5, 2026

    @yulunz
    Collaborator

    Confirmed. We'll apply Math.round(score * 100) to match the Lighthouse report.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions