fix(compiler): cap rendered diagnostics to avoid RangeError on large reports - #201
Open
techfreaque wants to merge 1 commit into
Open
fix(compiler): cap rendered diagnostics to avoid RangeError on large reports#201techfreaque wants to merge 1 commit into
techfreaque wants to merge 1 commit into
Conversation
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
force-pushed
the
fix-coverage-report-overflow
branch
from
August 22, 2026 09:29
4ecdc18 to
20dc90f
Compare
techfreaque
added a commit
to techfreaque/scriptc
that referenced
this pull request
Aug 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On a program with a very large number of diagnostics (thousands), the
scriptc coveragecommand crashes outright instead of printing a report:Root cause
The crash surfaces in
renderCoverage, but the actual cause is one level deeper:renderAll()inpackages/compiler/src/diagnostics/render.tsrenders 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-feelingRangeErrorinstead of showing the user anything at all, including the diagnostics that would have fit.renderCoverage's ownout.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 inrenderAll.Fix
Cap
renderAllat 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 exercisesrenderCoverage, including the code path that callsrenderAll) — all tests pass.tests/harness/diagnostics.test.ts(which exercisesrenderAlldirectly 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 onmain.