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

Coverage and test runs often result in JavaScript heap out of memory #5363

Closed
arr00 opened this issue Dec 12, 2024 · 5 comments · Fixed by #5382
Closed

Coverage and test runs often result in JavaScript heap out of memory #5363

arr00 opened this issue Dec 12, 2024 · 5 comments · Fixed by #5382

Comments

@arr00
Copy link
Contributor

arr00 commented Dec 12, 2024

On MacOS, vanilla runs of the test and coverage npm scripts often results in a JavaScript heap out of memory error. This is a known issue with hardhat NomicFoundation/hardhat#3471.

Increasing the allowed old memory to using the following env var fixes the issue NODE_OPTIONS="--max-old-space-size=8192". We should consider documenting this or even setting the env var by default.

@arr00 arr00 changed the title Coverage and Test runs often result in JavaScript heap out of memory Coverage and test runs often result in JavaScript heap out of memory Dec 12, 2024
@Amxx
Copy link
Collaborator

Amxx commented Dec 13, 2024

The .github/workflows/checks.yml contains

env:
  NODE_OPTIONS: --max_old_space_size=8192 

On my machine, I have it set in ~/.env, which is then sourced by ~/.zshrc.

I honestly think this is a very frequent error that is very well documented online. Should we make that default for everyone ? If we do so, could that cause issues on machine that have smaller ram ?

@Amxx
Copy link
Collaborator

Amxx commented Dec 13, 2024

For the record, if I type "JavaScript heap out of memory" in google, the first link I get is this, which contains all the information to solve that.

@arr00
Copy link
Contributor Author

arr00 commented Dec 13, 2024

I think we should set it by default--I'm not sure if it would cause issues on machines with too little memory... but the run would fail regardless for them.

@Amxx
Copy link
Collaborator

Amxx commented Dec 17, 2024

How would you set it ? Shipping a .env is considered bad practice

@arr00
Copy link
Contributor Author

arr00 commented Dec 17, 2024

We could prepend the npm scripts in package.json like so:

"test": "NODE_OPTIONS=\"--max-old-space-size=8192\" hardhat test"

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 a pull request may close this issue.

2 participants