Skip to content

fix(compiler): cap rendered diagnostics to avoid RangeError on large reports - #201

Open
techfreaque wants to merge 1 commit into
vercel-labs:mainfrom
techfreaque:fix-coverage-report-overflow
Open

fix(compiler): cap rendered diagnostics to avoid RangeError on large reports#201
techfreaque wants to merge 1 commit into
vercel-labs:mainfrom
techfreaque:fix-coverage-report-overflow

Conversation

@techfreaque

Copy link
Copy Markdown

Problem

On a program with a very large number of diagnostics (thousands), the scriptc coverage command crashes outright instead of printing a report:

file:///.../packages/compiler/dist/coverage/report.js:217
    return out.join("\n");
               ^
RangeError: Invalid string length
    at Array.join (<anonymous>)
    at renderCoverage (.../coverage/report.js:217:16)

Root cause

The crash surfaces in renderCoverage, but the actual cause is one level deeper: renderAll() in packages/compiler/src/diagnostics/render.ts renders every diagnostic — each carrying its own source-line context snippet — and joins them all into one string with no size limit. With enough diagnostics, the joined string exceeds V8's maximum string length, and the whole report crashes with an uncatchable-feeling RangeError instead of showing the user anything at all, including the diagnostics that would have fit.

renderCoverage's own out.join("\n") calls are bounded by report sections and grouped/deduplicated blockers, not raw diagnostic count, so they aren't a second unbounded site — the fix belongs entirely in renderAll.

Fix

Cap renderAll at 1000 rendered diagnostics (sorted, so the same diagnostics render first every time) and append a note stating how many were omitted and the true total, instead of silently truncating or crashing.

Verification

  • packages/compiler: tsc -p tsconfig.json — 0 errors.
  • tests/harness/coverage.test.ts (which exercises renderCoverage, including the code path that calls renderAll) — all tests pass.
  • tests/harness/diagnostics.test.ts (which exercises renderAll directly against a corpus of diagnostic-producing programs) — ran clean on the modified render logic; unrelated to this change, this suite currently has pre-existing snapshot path-normalization failures in this environment that reproduce identically on main.

@vercel

vercel Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

@mabr-pcvisit is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

…reports

renderAll() joined every diagnostic's rendered text (each with its own
source-line context) into one string with no size limit. On programs
with thousands of diagnostics, the joined string exceeds V8's max
string length and the whole report crashes with an uncatchable-feeling
RangeError instead of showing anything, including diagnostics that
would have fit. Cap the render at 1000 diagnostics and note how many
were omitted.
@techfreaque
techfreaque force-pushed the fix-coverage-report-overflow branch from 4ecdc18 to 20dc90f Compare August 22, 2026 09:29
techfreaque added a commit to techfreaque/scriptc that referenced this pull request Aug 22, 2026
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.

1 participant