apollographql / apollo-tooling

✏️ Apollo CLI for client tooling (Mostly replaced by Rover)
https://apollographql.com
MIT License
3.04k stars 468 forks source link

"yarn add apollo" crashes with out of memory #2506

Closed dmitry-yudakov closed 2 years ago

dmitry-yudakov commented 2 years ago

Update !!!!

The reason is circular dependency in https://github.com/oclif/oclif/issues/758

Original issue

Intended outcome: Successful installation.

Actual outcome: Yarn package manager crash with out of memory exception in clean project. Npm installation goes well.

How to reproduce the issue:

mkdir demo
cd demo
yarn init -y
yarn add apollo

Versions

yarn 1.22.17 apollo-2.33.9 (probably, since it's the latest current at the moment)

The result output of the operation.

$ yarn add apollo
yarn add v1.22.17
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
warning "apollo > apollo-language-server > @apollographql/graphql-language-service-interface@2.0.2" has incorrect peer dependency "graphql@^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0".
warning "apollo > apollo-language-server > @apollographql/graphql-language-service-interface > @apollographql/graphql-language-service-parser@2.0.2" has incorrect peer dependency "graphql@^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0".
warning "apollo > apollo-language-server > @apollographql/graphql-language-service-interface > @apollographql/graphql-language-service-types@2.0.2" has incorrect peer dependency "graphql@^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0".
warning "apollo > apollo-language-server > @apollographql/graphql-language-service-interface > @apollographql/graphql-language-service-utils@2.0.2" has incorrect peer dependency "graphql@^0.12.0 || ^0.13.0 || ^14.0.0".

<--- Last few GCs --->

[762:0x7f9c77300000]   104957 ms: Mark-sweep 4037.9 (4135.5) -> 4025.3 (4138.5) MB, 539.3 / 0.0 ms  (average mu = 0.217, current mu = 0.067) allocation failure scavenge might not succeed
[762:0x7f9c77300000]   105576 ms: Mark-sweep 4041.0 (4138.5) -> 4028.5 (4142.0) MB, 574.6 / 0.0 ms  (average mu = 0.149, current mu = 0.073) allocation failure scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x10ae7e8b1 node::Abort() [/usr/local/Cellar/node@16/16.13.0/libexec/node]
 2: 0x10ae7ea33 node::OnFatalError(char const*, char const*) [/usr/local/Cellar/node@16/16.13.0/libexec/node]
 3: 0x10afb9925 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/Cellar/node@16/16.13.0/libexec/node]
 4: 0x10afb98cf v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/Cellar/node@16/16.13.0/libexec/node]
 5: 0x10b0e243f v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/Cellar/node@16/16.13.0/libexec/node]
 6: 0x10b0e4c14 v8::internal::Heap::MarkCompactPrologue() [/usr/local/Cellar/node@16/16.13.0/libexec/node]
 7: 0x10b0e2a6f v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/Cellar/node@16/16.13.0/libexec/node]
 8: 0x10b0e0f21 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/Cellar/node@16/16.13.0/libexec/node]
 9: 0x10b0e96ef v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/Cellar/node@16/16.13.0/libexec/node]
10: 0x10b0e9cde v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/Cellar/node@16/16.13.0/libexec/node]
11: 0x10b0c7819 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/Cellar/node@16/16.13.0/libexec/node]
12: 0x10b35e1af v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/Cellar/node@16/16.13.0/libexec/node]
13: 0x10b5f70b9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/usr/local/Cellar/node@16/16.13.0/libexec/node]
14: 0x10b60c942 Builtins_ArrayPrototypeJoin [/usr/local/Cellar/node@16/16.13.0/libexec/node]
[1]    762 abort      yarn add apollo

I tried installing the peer dependencies and warnings go away but it still crashes.

I'm on Mac, I checked with few colleagues with ubuntu linux but the result is the same in all cases. Increasing the memory for node doesn't help.

I discovered it doing yarn upgrade of our project and was able to narrow it down to apollo package. It was working fine 4 days ago.

RvanderLaan commented 2 years ago

also getting this when installing an older pinned version using yarn add apollo@2.33.7. Our CI/CD keeps failing since a few hours because of this

I was thinking it might be some peer-peer dependency that received an update, but I'm not seeing any dependencies in the package.json with a ^ :thinking:

dmitry-yudakov commented 2 years ago

It seems the root cause is https://github.com/oclif/oclif/issues/758

ryandrewjohnson commented 2 years ago

I am also experiencing this issue. I have created a blank project with npm init and I'm just trying to install this package and no matter which version I try to install I get the memory issue.

RodEsp commented 2 years ago

There is a temporary fix out there for this now, please see https://github.com/oclif/oclif/issues/758#issue-1076987354 for more details.