Skip to content

fix(coverage): skip one unreadable server map without dropping later scripts - #1422

Merged
BenSheridanEdwards merged 1 commit into
mainfrom
fix/server-coverage-bad-entry
Nov 16, 2026
Merged

BenSheridanEdwards merged 1 commit into
mainfrom
fix/server-coverage-bad-entry

Conversation

@BenSheridanEdwards

Copy link
Copy Markdown
Owner

Why

readServerCoverage() wrapped the whole per-file loop in one try/catch. If one entry threw — a missing script, a sourceMappingURL whose .map was not on disk, a data: map that was not base64, or a malformed map — every later entry in that coverage file was abandoned. The catch was meant for a truncated coverage JSON, not for one bad script. The result is under-reported server script reach, which Change Reach can then read as not exercised.

Fixes #1415.

What changed

  • readCoverageEntries reads and parses one coverage JSON file; a truncated or invalid file still contributes no execution evidence.
  • tryResolveServerScript catches a bad entry so later entries in the same file are still mapped.
  • Those helpers were extracted so readServerCoverage stays at or under the fallow cognitive-complexity threshold of 15.
  • Tests cover a good entry, then a missing script, missing map, invalid non-base64 data: map, or malformed map, then another good entry: both neighbours survive. Invalid/truncated coverage JSON still supplies no evidence.
  • CHANGELOG records the fix under Unreleased.

Reviewer view

for (const entry of readCoverageEntries(file)) {
  const script = tryResolveServerScript(entry, projectRoot);
  if (script) scripts.push(script);
}

Proof

  • Tests: node --test test/server-coverage.test.mjs — red 8 passed, 4 failed (each bad-entry case kept before.js and lost after.js); green 12 passed, 0 failed. Both neighbour scripts are kept for missing-script, missing-map, invalid-data, and malformed-map cases. Invalid coverage JSON still supplies no evidence. Hooks-on pre-push on the Studio: 1254 passed, 1 skipped (11.7m).
  • Proof Law: this PR is false if a later good entry in the same coverage file is still dropped after a bad map; or if a truncated/invalid coverage JSON starts contributing execution evidence.
  • Screenshots: Not applicable. No report HTML or UI output changed.

Behaviour changes

  • A single unreadable server script or map no longer wipes later scripts from that coverage file. Unreadable coverage files themselves are still ignored.

Not asked for

Review guide

  • Start here: readServerCoverage in bin/server-coverage.mjs.
  • Then the new "bad server entry" and "invalid coverage JSON" cases in test/server-coverage.test.mjs.

Verification summary

  • Commands run: pnpm run build (test prerequisite dist/capture/map-io.js; no TypeScript was changed); pnpm exec prettier --write on the touched files; node --test test/server-coverage.test.mjs.
  • Results: red 8 passed, 4 failed; green 12 passed, 0 failed (including after extracting readCoverageEntries and tryResolveServerScript for fallow). Hooks-on pre-push on the Studio: 1254 passed, 1 skipped (11.7m). Raw insertions versus origin/main after prettier: 80/400 (bin/server-coverage.mjs 21, tests 59). CHANGELOG is excluded from that cap.
  • Unrelated failures: none in the focused run or the hooks-on pre-push.
  • Known risks or skipped checks: did not run pnpm run verify in the worktree before the hooks-on push; the Studio push ran the full pre-push suite instead.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Note

Live StyleProof-on-StyleProof (advisory). This report is captured from the surfaces declared in styleproof.config.ts (example/demo). home@* carries matching productState {id, revision} (comparable / certifying path); the product-state acknowledgement file stays armed but empty so undeclared new pairs fail closed. fail-on-diff is false; the check is not part of hosted required CI. The synthetic Action contract suite remains action-dogfood.yml.

🗺️ StyleProof report

Nothing changed, so no report was uploaded. The verdict is in the run summary.


Advisory-only mode: no reviewable changes detected — the StyleProof dogfood check remains green.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Note

Synthetic action dogfood receipt. This report is the final deliberately failing fixture in the action contract suite. It proves that unproven evidence is rejected; it does not certify this pull request.

🗺️ StyleProof report

📊 View the side-by-side visual report →


Coverage, determinism, report/diff consistency, or Change Reach (changeReach: 'gate') evidence is incomplete — this is not a base recapture failure. Repair the named evidence in the report.

@BenSheridanEdwards
BenSheridanEdwards force-pushed the fix/server-coverage-bad-entry branch 2 times, most recently from 2d59d43 to ba0335b Compare November 16, 2026 17:47
…scripts

readServerCoverage caught errors around the whole per-file loop, so one
bad script or map discarded every later entry. Parse the file separately
and skip only the failing entry.

Fixes #1415.
@BenSheridanEdwards
BenSheridanEdwards force-pushed the fix/server-coverage-bad-entry branch from ba0335b to 2416bac Compare November 16, 2026 18:10
@BenSheridanEdwards
BenSheridanEdwards merged commit e7f8207 into main Nov 16, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

One unreadable source map discards every later script in a server V8 coverage file

1 participant