yarn icon indicating copy to clipboard operation
yarn copied to clipboard

yarn command fail,prompt Reached heap limit Allocation failed - JavaScript heap out of memory。

Open Crest2333 opened this issue 2 years ago • 15 comments

C:\Users\38427>yarn -v 1.22.15

C:\Users\38427>yarn config list yarn config v1.22.15

<--- Last few GCs --->

[8180:000002315B904480] 604234 ms: Mark-sweep 10082.6 (10273.8) -> 10079.2 (10284.0) MB, 10573.7 / 0.0 ms (average mu = 0.322, current mu = 0.136) task scavenge might not succeed [8180:000002315B904480] 621640 ms: Mark-sweep 10091.9 (10284.0) -> 10086.2 (10290.5) MB, 17041.1 / 0.0 ms (average mu = 0.168, current mu = 0.021) task scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory 1: 00007FF70A1C013F v8::internal::CodeObjectRegistry::~CodeObjectRegistry+112495 2: 00007FF70A14F396 DSA_meth_get_flags+65526 3: 00007FF70A15024D node::OnFatalError+301 4: 00007FF70AA819EE v8::Isolate::ReportExternalAllocationLimitReached+94 5: 00007FF70AA6BECD v8::SharedArrayBuffer::Externalize+781 6: 00007FF70A90F61C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1468 7: 00007FF70A90C754 v8::internal::Heap::CollectGarbage+4244 8: 00007FF70A8BC3B5 v8::internal::IndexGenerator::~IndexGenerator+22165 9: 00007FF70A0E0E9F v8::CFunctionInfo::HasOptions+22111 10: 00007FF70A0DF6B6 v8::CFunctionInfo::HasOptions+15990 11: 00007FF70A21F25B uv_async_send+331 12: 00007FF70A21E9EC uv_loop_init+1292 13: 00007FF70A21EB8A uv_run+202 14: 00007FF70A1EDC95 node::SpinEventLoop+309 15: 00007FF70A107AC3 cppgc::internal::NormalPageSpace::linear_allocation_buffer+53827 16: 00007FF70A184FBD node::Start+221 17: 00007FF709FA88CC RC4_options+348108 18: 00007FF70B0008F8 v8::internal::compiler::RepresentationChanger::Uint32OverflowOperatorFor+14472 19: 00007FFAE08A4034 BaseThreadInitThunk+20 20: 00007FFAE3013691 RtlUserThreadStart+33

Crest2333 avatar Nov 25 '21 07:11 Crest2333

Similar issue when install purgecss-webpack-plugin in some situation: https://github.com/FullHuman/purgecss/issues/700

Reproduction

This is my very basic repo https://github.com/teekenl/test-purge-css, so if you pulled down and run yarn install before trying to run yarn add purgecss-webpack-plugin you will get the error.

Copy of the issue above

Describe the bug Got into memory exceeded limit error when trying to install the plugin using yarn

To Reproduce Steps to reproduce the behavior:

  1. Go to terminal - install
  2. Run yarn add purgecss-webpack-plugin
  3. See error

Note: have tried the following:

  1. export NODE_OPTIONS= --max_old_space_size=16000

Expected behavior should install successfully

Screenshots

❯ yarn add purgecss-webpack-plugin                
yarn add v1.22.10
[1/5] 🔍  Validating package.json...
[2/5] 🔍  Resolving packages...
[3/5] 🚚  Fetching packages...
[4/5] 🔗  Linking dependencies...
warning " > [email protected]" has incorrect peer dependency "webpack@^3.1.0".
warning " > [email protected]" has incorrect peer dependency "webpack@1 || 2 || 3".
<--- Last few GCs --->
[1585:0x1046ab000]   934298 ms: Scavenge (reduce) 15963.4 (16020.1) -> 15963.0 (16020.6) MB, 27.0 / 0.0 ms  (average mu = 0.278, current mu = 0.207) allocation failure 
[1585:0x1046ab000]   934322 ms: Scavenge (reduce) 15963.7 (16017.6) -> 15963.3 (16018.9) MB, 21.4 / 0.0 ms  (average mu = 0.278, current mu = 0.207) allocation failure 
[1585:0x1046ab000]   934345 ms: Scavenge (reduce) 15964.0 (16020.9) -> 15963.7 (16021.4) MB, 20.4 / 0.0 ms  (average mu = 0.278, current mu = 0.207) allocation failure 
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x1012d96a5 node::Abort() (.cold.1) 
 2: v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) 
 3: 0x100395df5 v8::internal::Heap::FatalProcessOutOfMemory(char const*)
 4: 0x10039789a v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) 

Environment (please complete the following information):

  • Node version - 14.15.5
  • OS: 10.15.7
  • Package - purgecss
  • yarn version - 1.9.4

Ffloriel avatar Nov 28 '21 23:11 Ffloriel

I have set NODE_OPTIONS=16000,but, still fail,any yarn command will fail,except yarn -v. My Environment Node version - 14.18.1 OS: win 10 Package - purgecss yarn version - 1.22.17 image

Crest2333 avatar Nov 29 '21 02:11 Crest2333

Suddenly started facing the same issue, tried updating to latest v1 and changing node versions but no luck so far :(

alvaroschipper avatar Dec 02 '21 14:12 alvaroschipper

me too, i have change anything, there is no resolution for this problem?

EmanoelFaria avatar Dec 10 '21 01:12 EmanoelFaria

+1, just started happening today with yarn add

ttomaszewski avatar Dec 10 '21 04:12 ttomaszewski

Happening with netlify-cli too https://github.com/netlify/cli/issues/3788 without any change to the CLI.

Happens with multiple versions of the CLI, Node.js and Yarn

erezrokah avatar Dec 10 '21 11:12 erezrokah

Opened an issue on the dependency that's causing it for netlify-cli, see https://github.com/oclif/plugin-help/issues/349.

However this is a yarn issue as using npm works.

erezrokah avatar Dec 10 '21 14:12 erezrokah

I work with @erezrokah on netlify-cli. From our additional debugging, it seems like the problem is happening due to a circular dependency between two packages (i.e. they depend on each other). In our case, it is @oclif/plugin-help and @oclif/command. However, the bug only triggers when also using the npm: prefix on the version of one of them, as shown here.

ehmicky avatar Dec 10 '21 15:12 ehmicky

having a similar issue, not sure what's causing it

warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > zeal-ui > [email protected]" has unmet peer dependency "react@*".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > zeal-ui > [email protected]" has unmet peer dependency "react-native@*".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > @testing-library/[email protected]" has unmet peer dependency "react@>=16.9.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > @testing-library/[email protected]" has unmet peer dependency "react-test-renderer@>=16.9.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > [email protected]" has unmet peer dependency "jest@>=26 <27".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > brgr > react-native > react-native-codegen > [email protected]" has unmet peer dependency "@babel/preset-env@^7.1.6".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > eslint-config-universe > @typescript-eslint/[email protected]" has incorrect peer dependency "eslint@^5.0.0 || ^6.0.0 || ^7.0.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > eslint-config-universe > @typescript-eslint/[email protected]" has incorrect peer dependency "eslint@^5.0.0 || ^6.0.0 || ^7.0.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > jest-expo > [email protected]" has unmet peer dependency "react@^16.0.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > jest-expo-enzyme > @wojtekmaj/[email protected]" has unmet peer dependency "react@^17.0.0-0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > jest-expo-enzyme > @wojtekmaj/[email protected]" has unmet peer dependency "react-dom@^17.0.0-0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > jest-expo-enzyme > [email protected]" has unmet peer dependency "jest@>=22.0.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > jest-expo-enzyme > [email protected]" has unmet peer dependency "[email protected]".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > jest-expo-enzyme > @wojtekmaj/enzyme-adapter-react-17 > @wojtekmaj/[email protected]" has unmet peer dependency "react@^17.0.0-0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > jest-expo-enzyme > jest-enzyme > [email protected]" has unmet peer dependency "jest@>=22.0.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > jest-expo-enzyme > jest-enzyme > [email protected]" has unmet peer dependency "react@^0.13.0 || ^0.14.0 || ^15.0.0 || >=16.x".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > expo-paymob > expo-module-scripts > jest-expo-enzyme > jest-expo > [email protected]" has unmet peer dependency "jest@^26.0.0 || ^27.0.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > [email protected]" has unmet peer dependency "react-native-web@>= 0.11".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > dashboard > [email protected]" has incorrect peer dependency "react-native@>=0.65.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > [email protected]" has incorrect peer dependency "@klarna/react-native-vector-drawable@^0.1.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > [email protected]" has unmet peer dependency "metro@>=0.58.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > [email protected]" has unmet peer dependency "metro-config@>=0.58.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > [email protected]" has unmet peer dependency "@types/react@*".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > [email protected]" has unmet peer dependency "react-dom@*".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > react-native-map-link > [email protected]" has incorrect peer dependency "react-native@>=0.65.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > native-base > @react-native-aria/[email protected]" has unmet peer dependency "react-dom@*".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > team > expo-camera > @koale/[email protected]" has incorrect peer dependency "react@^16.8.0".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > coffee-berry > react-native > react-native-codegen > [email protected]" has unmet peer dependency "@babel/preset-env@^7.1.6".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > native-base > @react-native-aria/combobox > @react-aria/[email protected]" has unmet peer dependency "react-dom@^16.8.0 || ^17.0.0-rc.1".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > native-base > @react-native-aria/combobox > @react-aria/[email protected]" has unmet peer dependency "react-dom@^16.8.0 || ^17.0.0-rc.1".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > native-base > @react-native-aria/combobox > @react-aria/[email protected]" has unmet peer dependency "react-dom@^16.8.0 || ^17.0.0-rc.1".
warning "workspace-aggregator-0ca2fd29-e466-460e-a4c6-d00b7cadd778 > ego > native-base > @react-native-aria/combobox > @react-aria/combobox > @react-aria/[email protected]" has unmet peer dependency "react-dom@^16.8.0 || ^17.0.0-rc.1".

<--- Last few GCs --->

[35655:0x7fb3e0008000]   132757 ms: Scavenge 4040.7 (4122.2) -> 4037.9 (4123.7) MB, 27.1 / 0.0 ms  (average mu = 0.341, current mu = 0.357) allocation failure
[35655:0x7fb3e0008000]   133114 ms: Scavenge 4042.1 (4123.7) -> 4040.0 (4126.5) MB, 316.0 / 0.0 ms  (average mu = 0.341, current mu = 0.357) allocation failure
[35655:0x7fb3e0008000]   133935 ms: Scavenge 4045.3 (4126.5) -> 4042.6 (4144.5) MB, 805.2 / 0.0 ms  (average mu = 0.341, current mu = 0.357) allocation failure


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0x10ea3ea25 node::Abort() (.cold.1) [/usr/local/bin/node]
 2: 0x10d7340f9 node::Abort() [/usr/local/bin/node]
 3: 0x10d73426f node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 4: 0x10d8b5787 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 5: 0x10d8b5723 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 6: 0x10da56e05 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
 7: 0x10da5578c v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
 8: 0x10da62030 v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
 9: 0x10da620b1 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
10: 0x10da2f147 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/bin/node]
11: 0x10dde6d4e v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
12: 0x10e190819 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/usr/local/bin/node]
[1]    35655 abort      yarn

a-eid avatar May 04 '22 05:05 a-eid

I encountered this same error upgrading packages that also had a resolutions entry in package.json. I was able to work-around the error by removing the resolutions and trying again.

deleteme avatar Nov 21 '22 18:11 deleteme

Same issue FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory Neither yarn cache clean nor export NODE_OPTIONS=--max_old_space_size=8192 doesn't help.

lossen avatar Feb 27 '23 05:02 lossen

I think that this happened to me just after clearing the cache with yarn cache clean

obayit avatar Mar 14 '23 15:03 obayit

I found a solution at https://stackoverflow.com/questions/57923800/yarn-build-in-reactjs-allocation-failed-javascript-heap-out-of-memory

andrewgreenhill avatar Apr 20 '23 13:04 andrewgreenhill

I deleted yarn.lock and then ran yarn install and everything installed as expected 🤷‍♂️

kesha-antonov avatar Jul 07 '23 09:07 kesha-antonov

I added the yarn.lock which was generated by another machine and the heap error was resolved.

HoseinGhanbari avatar Sep 23 '23 15:09 HoseinGhanbari