fix(tests): prevent v8 coverage segfault on large codebase #877
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.
Summary
Fixes segmentation fault when running
pnpm coverby implementing memory management and processing concurrency options for v8 coverage on our large test suite.Requires #875.
Changes
1. Logger Hoisting (
scripts/cover.mjs)const logger = getDefaultLogger()to module scope2. Memory Management (
package.json)test:unit:coveragescript to useNODE_OPTIONSenvironment variable--max-old-space-size=8192to increase Node.js heap memory limit3. V8 Coverage Configuration (
vitest.config.mts)processingConcurrency: 1to prevent parallel processing overloadreportOnFailure: truefor better error reportingreportsDirectory: './coverage'path4. Updated Coverage Badges (
README.md)Problem
The v8 coverage provider was segfaulting with
SIGSEGVwhen processing our test suite:Root Cause
V8 coverage was attempting to process too much data simultaneously without sufficient memory allocation, causing the Node.js process to crash with a segmentation fault.
Solution
processingConcurrency: 1)Test Results
✓ Coverage now completes successfully:
Related
This fix enables reliable coverage reporting for our large test suite and unblocks future coverage tracking improvements.