question-mark
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.

Huge memory leak with Jest/Enzyme after upgrading to react-modal 3.X

See original GitHub issue

Summary:

For a while now, I’ve been unable to upgrade to react-modal 3.X in my React 16 project with Jest/Enzyme because when I run tests Node itself actually crashes and I usually have to take some fairly nuclear steps such as force-quitting the process in my activity monitor app in order to use it again. The latest 2.X release of react-modal is totally fine.

Steps to reproduce:

  1. Upgrade react-modal from 2.4.1 to 3.X
  2. Run npm run jest
  3. First few tests may run, but eventually the process hangs, and eventually these errors start to spill out:
<--- Last few GCs --->

[46548:0x102802400]    43615 ms: Mark-sweep 1402.9 (1437.6) -> 1402.9 (1436.6) MB, 1477.5 / 0.0 ms  (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 1477 ms) last resort GC in old space requested
[46548:0x102802400]    45072 ms: Mark-sweep 1402.9 (1436.6) -> 1402.9 (1436.6) MB, 1456.0 / 0.0 ms  last resort GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x38a049725ec1 <JSObject>
    1: read [/path/to/project/node_modules/react-dom/cjs/react-dom-server.node.development.js:~2206] [pc=0x181429965313](this=0x38a08a383211 <ReactDOMServerRenderer map = 0x38a00fd8cc29>,bytes=0x38a0125029a9 <Number inf>)
    3: renderToStaticMarkup [/path/to/project/node_modules/react-dom/cjs/react-dom-server.node.development.js:2512] [bytecode=0x38a0...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [/Users/username/.nvm/versions/node/v8.9.0/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/Users/username/.nvm/versions/node/v8.9.0/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/Users/username/.nvm/versions/node/v8.9.0/bin/node]
 4: v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/Users/username/.nvm/versions/node/v8.9.0/bin/node]
 5: v8::internal::Runtime_AllocateInTargetSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/Users/username/.nvm/versions/node/v8.9.0/bin/node]
 6: 0x18142970463d

*Note that I’ve replaced the actual path and username in this snippet.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:9
  • Comments:43

github_iconTop GitHub Comments

1reaction
asborisovcommented, Mar 10, 2018

I downgrade to 2.4.2 and looks it work now. Will wait until correct fix is merged

1reaction
diasbrunocommented, Mar 9, 2018

@asborisov @rharriso Follow the react issue I’ve mention here. Many ideas/workaround have been publish there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Finding the cause of a memory leak in Jest tests
We've managed to fix the problem after a couple of hours, and we'd like to share the process of how we found the...
Read more >
How to fix the React memory leak warning - DEV Community ‍ ‍
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your...
Read more >
Hunting JS memory leaks in React Native apps
In this article, we gathered the typical approaches to debug and solve memory problems in a React Native app. If your app happens...
Read more >
update state in react Code Example - Code Grepper
3. Replace the property you're intested in. 7. item.name = 'newName';. 8. // 4. Put it back into our array. N.B. we *are*...
Read more >
Your Jest Tests are Leaking Memory
Jest is designed in a way that makes memory leaks likely if you're ... a memory leak, and then how to debug and...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found