Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"nyc report" loads all reports in tempDirectory into memory #805

Closed
RyanV opened this issue Apr 3, 2018 · 0 comments
Closed

"nyc report" loads all reports in tempDirectory into memory #805

RyanV opened this issue Apr 3, 2018 · 0 comments
Labels

Comments

@RyanV
Copy link
Contributor

RyanV commented Apr 3, 2018

Expected Behavior

when a directory has multiple report files, running nyc report ... should read, parse, and merge each report file one by one.

See original istanbul behavior:
https://github.com/gotwarlost/istanbul/blob/master/lib/command/report.js#L109
https://github.com/gotwarlost/istanbul/blob/master/lib/collector.js#L71

Observed Behavior

All reports are read into memory before any merging occurs which, on some machines, causes a FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - Javascript heap out of memory error.

See:
https://github.com/istanbuljs/nyc/blob/master/index.js#L428
https://github.com/istanbuljs/nyc/blob/master/index.js#L517

Background

The project I am working on has many integration tests (1500+) that use instrumented versions of multiple JS builds, each of which write a new coverage report. Each file is between 2.5mb - 4mb.

Temporary Workaround

If anyone else stumbles upon this and needs a temporary workaround, I wrote a quick basic script to merge the results to a single file which you can then use when calling nyc report ...
https://gist.github.com/RyanV/6fe44b80082a8eb609199bfb0e8da953

Or if you have the memory to spare, increase the heap size allocation by passing the flag node --max-old-space-size=[size] nyc ..., where [size] is a number value in megabytes.

Forensic Information

OS: Mac, Windows
Node Version: 7.9.0
NPM Version: 4.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants