cli icon indicating copy to clipboard operation
cli copied to clipboard

"react-native start" ends with "out of memory"-failure on Node >=12.5

Open PK-INTENSIO opened this issue 7 years ago • 23 comments

EDIT: Workaround

Downgrade to Node 12.4, see https://github.com/react-native-community/cli/issues/485#issuecomment-509210382.

Environment

System: OS: Windows 10 CPU: (4) x64 Intel(R) Core(TM) i7-4510U CPU @ 2.00GHz Memory: 5.40 GB / 7.88 GB Binaries: Node: 12.6.0 - C:\Program Files\nodejs\node.EXE npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: Version 3.4.0.0 AI-183.6156.11.34.5522156

Description

"react-native start" ends with "out of memory"-failure

C:\Temp\FRNA>react-native start ┌──────────────────────────────────────────────────────────────────────────────┐ │ │ │ Running Metro Bundler on port 8081. │ │ │ │ Keep Metro running while developing on any JS projects. Feel free to │ │ close this tab and run your own Metro instance if you prefer. │ │ │ │ https://github.com/facebook/react-native │ │ │ └──────────────────────────────────────────────────────────────────────────────┘

Looking for JS files in C:\Temp\FRNA

Loading dependency graph... <--- Last few GCs --->

[3844:00000135069CA290] 9074 ms: Scavenge 65.9 (93.0) -> 51.0 (93.0) MB, 4.1 / 0.0 ms (average mu = 0.998, current mu = 0.998) allocation failure

<--- JS stacktrace --->

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

0: ExitFrame [pc: 00007FF6C4CF170D]
1: InternalFrame [pc: 00007FF6C4C659EB]

Security context: 0x029a341c0911 2: next [0000029A341E29A9](this=0x02a8d7380881 ,0x022c4d995851 <JSArray[18398]>) 3: asyncGeneratorStep(aka asyncGeneratorStep) [000000039D6EBEA1] [C:\Temp\FRNA\node_modules\jest-haste-map\build\index.js:193] [bytecode=00000340235B2529 offset=11](this=0x00bbe6dc04d1 ,0x02a8d7380881 ...

FATAL ERROR: Zone Allocation failed - process out of memory 1: 00007FF6C44B962F 2: 00007FF6C4462376 3: 00007FF6C4463036 4: 00007FF6C4C48A1E 5: 00007FF6C4C30D6A 6: 00007FF6C4758E9D 7: 00007FF6C4F7CD34 8: 00007FF6C4F7C7AD 9: 00007FF6C4F7B3BF 10: 00007FF6C50E9C26 11: 00007FF6C50C7BD6 12: 00007FF6C4FC037A 13: 00007FF6C4FDD009 14: 00007FF6C4FDD5D4 15: 00007FF6C4FDD366 16: 00007FF6C4FC150E 17: 00007FF6C4FBEAA1 18: 00007FF6C4FBAF4B 19: 00007FF6C4B7DA77 20: 00007FF6C4B7D3D1 21: 00007FF6C4B7A4A3 22: 00007FF6C48AF317 23: 00007FF6C4CF170D 24: 00007FF6C4C659EB 25: 00007FF6C4C93585 26: 00007FF6C4C65BBC 27: 00007FF6C4C65BBC 28: 00007FF6C4CB9FC2 29: 00007FF6C4C84BB2 30: 00007FF6C4C633DC 31: 00007FF6C4B0DF24 32: 00007FF6C4B0E033 33: 00007FF6C4B0E702 34: 00007FF6C49E6A05 35: 00007FF6C4C6678C 36: 00000268F35536F3

Reproducible Demo

run "react-native init FRNA" run "react-native start"

PK-INTENSIO avatar Jul 05 '19 14:07 PK-INTENSIO

Kindly put the output of react-native --version here.

thecodrr avatar Jul 05 '19 14:07 thecodrr

I'm facing the same issue.

Just updated from node v11.7 to 12.6, and now the command "react-native start" progressively consumes the entire system memory.

OS Linux Mint 19.1 Tessa - 4.15.0-54-generic x86_64

npm -v 6.9.0

node -v v12.6.0

react-native --version react-native-cli: 2.0.1 react-native: 0.60.0

Rolling back to the previous node version solves the issue

erik-tartaglia avatar Jul 07 '19 19:07 erik-tartaglia

Interesting. Are you able to provide a repro case we can download and investigate?

thymikee avatar Jul 07 '19 19:07 thymikee

Interesting. Are you able to provide a repro case we can download and investigate?

It was a new empty project without any modification:

$ react-native init hello && cd hello && react-native start
This will walk you through creating a new React Native project in /home/tartagliaeg/dev/hello
Using yarn v1.16.0
Installing react-native...
yarn add v1.16.0
info No lockfile found.
[1/4] Resolving packages...
[...]

image

erik-tartaglia avatar Jul 07 '19 21:07 erik-tartaglia

This will need to be tested and reproduced. Maybe there is a memory leak somewhere....

thecodrr avatar Jul 07 '19 21:07 thecodrr

Same problem

I had node v.12.6, downgrading to a previous version solves the issue.

Environment

System: OS: Linux 4.18 Ubuntu 18.04.2 LTS (Bionic Beaver) CPU: (4) x64 Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz Memory: 155.97 MB / 3.72 GB Binaries: Node: 10.16.0 - /usr/local/bin/node npm: 6.9.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman npmPackages: react: 16.8.6 => 16.8.6 react-native: 0.60.0 => 0.60.0

zerohex-eth avatar Jul 08 '19 02:07 zerohex-eth

@Dom-Mac seems a problem with node rather than react-native-cli

thecodrr avatar Jul 08 '19 03:07 thecodrr

Downgrading to node v.12.4.0 solved my issue on Windows 10, too. node v 12.5.0 has the same problem as v 12.6.0.

react-native-cli: 2.0.1 react-native: 0.60.0

PK-INTENSIO avatar Jul 08 '19 10:07 PK-INTENSIO

Possibly related issues in Node.js:

  • https://github.com/nodejs/node/issues/28558
  • https://github.com/nodejs/node/issues/28571

Closing, as that's unrelated to this CLI. Please send your detailed reports to Node.js maintainers.

thymikee avatar Jul 08 '19 12:07 thymikee

I have same issue, when I run yarn start, metro start eating memory (> 10GB) with 100% cpu usage.

this my package dependencies. when I remove lint-staged, metro works as alright.

  "devDependencies": {
    "@babel/core": "^7.5.4",
    "@babel/runtime": "^7.5.4",
    "@types/jest": "^24.0.15",
    "@types/react": "^16.8.23",
    "@types/react-native": "^0.60.0",
    "@types/react-test-renderer": "^16.8.2",
    "@typescript-eslint/eslint-plugin": "^1.12.0",
    "@typescript-eslint/parser": "^1.12.0",
    "babel-jest": "^24.8.0",
    "eslint": "^6.0.1",
    "eslint-config-prettier": "^6.0.0",
    "eslint-plugin-import": "^2.18.0",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-prettier": "^3.1.0",
    "eslint-plugin-react": "^7.14.2",
    "eslint-plugin-react-hooks": "^1.6.1",
    "husky": "^3.0.0",
    "jest": "^24.8.0",
    "lint-staged": "^9.2.0",
    "metro-react-native-babel-preset": "^0.55.0",
    "prettier": "^1.18.2",
    "react-test-renderer": "16.8.6",
    "typescript": "^3.5.3"
  },

downgrading node solved it.

sijad avatar Jul 14 '19 04:07 sijad

I'm getting this error too, the memory consumption grows and freeze my system... Already tried using v12.4.0 as suggested but still got the same

gdguesser avatar Jul 25 '19 13:07 gdguesser

On osx 10.14.6 rolled all the way down to 10 to get this to work for me;

brew uninstall node brew install node@10

stevesweets avatar Jul 31 '19 17:07 stevesweets

On windows 10 build 18362 version 12.5/12.4 still got the leak. 10.16.1 works fine.

eperedo avatar Aug 01 '19 15:08 eperedo

There's a PR fixing it in upstream jest-haste-map package: https://github.com/facebook/jest/pull/8787. Please test it and report back if it works for you

thymikee avatar Aug 06 '19 13:08 thymikee

Actually the "fix" in jest-haste-map is just a workaround.

Here's a minimal reproduction of the node bug and a description of my findings: https://github.com/nodejs/node/issues/29001

niieani avatar Aug 06 '19 15:08 niieani

@thymikee I must admit, I'm confused on how to try the workaround. If I follow the CONTRIBUTING doc and yarn link to a jest checkout of the patch-3 branch with the workaround, that will link in all the packages as well, so I would get the jest-haste-map modifications?

Or maybe it would be faster to checkout the branch, build it, then just copy the built JS in there (and maybe create a patch-package patch so it's sticky)? I'm going to try this as I don't have confidence in the yarn link idea

I will say I really love the way the reactxp framework distributes it's typescript and it's javascript, along with the necessary 'npm run build' command so that you can attempt hackery like this inside node_modules directly without any sort of fork/clone/build/copy messing around for quick tests - lowers the barrier to QA, but that's more of a "wouldn't it be nice..." thought for here for the future maybe :-)

mikehardy avatar Aug 09 '19 21:08 mikehardy

@mikehardy since this is relatively small change I'd patch it manually in node_modules

thymikee avatar Aug 09 '19 21:08 thymikee

Workaround tested and working! status (and patch-package patch) attached to comment on PR https://github.com/facebook/jest/pull/8787#issuecomment-520091960

mikehardy avatar Aug 09 '19 23:08 mikehardy

Patch is for 24.8.0, but current module version is 24.8.1. Is it possible to get a path for the current version?

patch-package 6.1.2 Applying patches...

ERROR Failed to apply patch for package jest-haste-map at path

node_modules/jest-haste-map

This error was caused because jest-haste-map has changed since you made the patch file for it. This introduced conflicts with your patch, just like a merge conflict in Git when separate incompatible changes are made to the same piece of code.

Maybe this means your patch file is no longer necessary, in which case hooray! Just delete it!

Otherwise, you need generate a new patch file.

To generate a new one, just repeat the steps you made to generate the first one.

i.e. manually make the appropriate file changes, then run

patch-package jest-haste-map

Info: Patch file: patches/jest-haste-map+24.8.0.patch Patch was made for version: 24.8.0 Installed version: 24.8.1

cfantasy74 avatar Aug 15 '19 08:08 cfantasy74

You'll have to hack it @cfantasy74 - just remove the hunk from crawlers/node.js (that file is modified for 24.8.0 but not needed for 24.8.1) and rename to the new patch version

mikehardy avatar Aug 15 '19 14:08 mikehardy