Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JavaScript heap out of memory

See original GitHub issue

🐛 Bug Report

I wanted to test out fast-check, so I wrote a simple function with a single property test. My test generates two integers and a natural number. If I set a precondition on one of the integers that it can’t equal zero, the test suite fails to finish and fails with a heap space exception.

const _ = require("lodash");
const fc = require("fast-check");

const divisibleCount = (x, y, k) => {
  return _.chain(y - x)
    .map(n => x + n)
    .reject(n => n % k)

test("works", () => {
  fc.assert(, fc.integer(), fc.nat(), (x, k, n) => {
      fc.pre(k !== 0);
      let y = x + n * k;
      return n === divisibleCount(x, y, k);

It seems like the suite runs to completion without the precondition, but I’m guessing this is because k = 0 causes the function under test to fail, so it doesn’t go through a large number of combinations.

To Reproduce

I pushed my simple repo that recreates the issue for me. Just clone it, and run the test suite.

Steps to reproduce:

git clone \
cd count_the_divisible_numbers \
yarn \
yarn test

Expected behavior

I would expect the test suite to pass, or at least to run to completion. Instead, I’m getting a “JavaScript heap out of memory” error:

FATAL ERROR: invalid table size Allocation failed - JavaScript heap out of memory
 1: 0x10007e71b node::Abort() [/Users/pcorey/.nvm/versions/node/v12.12.0/bin/node]
 2: 0x10007e89f node::OnFatalError(char const*, char const*) [/Users/pcorey/.nvm/versions/node/v12.12.0/bin/node]
 3: 0x100176137 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/Users/pcorey/.nvm/versions/node/v12.12.0/bin/node]
 4: 0x1001760d3 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/pcorey/.nvm/versions/node/v12.12.0/bin/node]

Your environment

Packages / Softwares Version(s)
fast-check 1.19.0
node 12.12.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

ca-dcommented, Sep 21, 2022

@pcorey @dubzzz I don’t know what it says about the state of communication on the wider web in general, but I feel the strong urge to point out how much my heart was warmed by the mutually constructive, respectful, and kind way in which the two of you exchanged feedback on each other’s code in this thread. Thank you ❣️

pcoreycommented, Nov 22, 2019

No worries. Thanks for the help @dubzzz.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix JavaScript Heap Out of Memory Error - MakeUseOf
A common problem while working on a JavaScript Node.js project is the “JavaScript heap out of memory” error. This error usually occurs when ......
Read more >
Node.js heap out of memory - javascript - Stack Overflow
I have a 64-bit CPU and I've installed x86 node version, which caused the CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory ......
Read more >
JavaScript heap out of memory - Snyk Support
This generally occurs on larger projects where the default amount of memory allocated by Node (1.5gb) is insufficient to complete the command successfully....
Read more >
How to solve JavaScript heap out of memory error
To fix JavaScript heap out of memory error, you need to add the --max-old-space-size option when running your npm command. ... Alternatively, you ......
Read more >
JavaScript Heap Out Of Memory Error - OpenReplay Blog
A quick solution that you can use to fix "Heap Out Of Memory Error" in JavaScript. We lay out the causes and how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found