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.

Out of memory or out of time when compiling large JS files

See original GitHub issue

Do you want to request a feature or report a bug? Bug.

What is the current behavior? Metro will either run out of memory or it will give up after 5 minutes of waiting to transform the JS file.

This was first reported here https://github.com/facebook/react-native/issues/8475 and then again here https://github.com/facebook/react-native/issues/12590

If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test. I have a repro repo here https://github.com/jeaye/react-native-packager-bug – it’s not in the yarn format, since I don’t know what that is.

What is the expected behavior? The transformation completes in a timely fashion or metro waits long enough for the transformation to finish in however long it needs. In order to achieve the latter, my production build script currently contains the following:

metro=../node_modules/metro-bundler/src/JSTransformer/index.js
sed -i 's/\(TRANSFORM_TIMEOUT_INTERVAL\) = .*;/\1 = 901000;/g' "$metro" || true

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.

React Native: 0.50.4 babel-preset-react-native: 4.0.0 Metro (comes with RN): 0.20.3 Node: 9.3.0 OS: Arch Linux x86_64

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:10
  • Comments:25 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
jeayecommented, Feb 10, 2018

@roesneb It certainly shouldn’t be closed. It was ignored when it was reported, multiple times, in the react native repo, while people suggested it be brought up here. Now that it’s brought up here, it’s promptly closed and no workarounds are available (for people using ClojureScript).

For your problem, you might try ignoring that JSON file using your babelrc. Alas, if it has a common name, then all JSONs with that name will be ignored, which is the last problem about which I asked @rafeca.

2reactions
HikingDevcommented, Feb 10, 2018

Why is this issue closed? I have a json file with 17.4MB. If i require it the bundler crashes and if comment it out everything works fine. This seems to be a common problem. Is there a solution for this issue?

“FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory”

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript Heap Out Of Memory Error | Felix Gerschau
This error indicates high memory usage or a memory leak in your application. In this article, I cover different solutions to this problem....
Read more >
Node.js heap out of memory - Stack Overflow
Today I ran my script for filesystem indexing to refresh RAID files index and after 4h it crashed with following error:
Read more >
Webpack: How to fix "Heap out of memory - m4x
This happens because Webpack recreates the file tree in memory with everything you import from your entry files (e.g. index. js).
Read more >
How to Fix JavaScript Heap Out of Memory Error - MakeUseOf
How to Fix JavaScript Heap Out of Memory on Windows · Open the Start menu, search for Advanced System Settings, and select the...
Read more >
Workarounds for Out of Memory Crashes | manual
Large Javascript. When you use "allowJs": true , Typescript may try to compile Javascript packages inside node_modules . Large Javascript libraries still crash ......
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