mulesoft-labs / api-console-cli

A CLI tools for the API console.
Other
14 stars 15 forks source link

Fatal Error on Build (Heap out of memory) #36

Closed vanadar closed 4 years ago

vanadar commented 5 years ago

Hello,

I'am unabled to build our documentation, when doing an api-console build -a raml/api-interne.raml -t "RAML 1.0" I end up with the following error : FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

I've tried to increase the memory up to ~10G, which allow me to build if i reduce my documentation to a 1/4

It seems to be related with the schema generation (I have around 500 JSON schemas to generate)

Do you have any ideas on how to i can solve my problem ?

Here is my command and the full error:

export NODE_OPTIONS=--max_old_space_size=10000 && api-console build -a raml/api-interne.raml -t "RAML 1.0" --verbose
info: Generating API model from raml/api-interne.raml, using RAML 1.0 parser
debug: Initializing AMF library...
debug: AMF ready.
debug: Running API parser...

<--- Last few GCs --->

[4950:0x103800000]   180300 ms: Scavenge 9974.6 (10168.3) -> 9974.2 (10168.8) MB, 20.1 / 0.0 ms  (average mu = 0.134, current mu = 0.081) allocation failure
[4950:0x103800000]   180322 ms: Scavenge 9974.8 (10168.8) -> 9974.5 (10169.8) MB, 19.9 / 0.0 ms  (average mu = 0.134, current mu = 0.081) allocation failure
[4950:0x103800000]   180346 ms: Scavenge 9975.2 (10169.8) -> 9974.8 (10170.3) MB, 20.5 / 0.0 ms  (average mu = 0.134, current mu = 0.081) allocation failure

<--- JS stacktrace --->

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

    0: ExitFrame [pc: 0xc8501a5be3d]
Security context: 0x399c3bc9e6e1 <JSObject>
    1: kLa [0x399c021b7421] [/Users/vanadar/.npm-packages/lib/node_modules/api-console-cli/node_modules/amf-client-js/amf.js:~1655] [pc=0xc850236a2ed](this=0x399cb589ad11 <JSGlobal Object>,a=0x399e8f0fe0d9 <RG map = 0x399c3ef218e9>)
    2: nLa [0x399c021b72e1] [/Users/vanadar/.npm-packages/lib/node_modules/api-console-cli/node_modules/amf-client-js/amf.js:~1654] ...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x10003b1db node::Abort() [/usr/local/bin/node]
 2: 0x10003b3e5 node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 3: 0x1001a86b5 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 4: 0x100573ad2 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
 5: 0x1005765a5 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/usr/local/bin/node]
 6: 0x10057244f v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
 7: 0x100570624 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
 8: 0x10057cebc v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
 9: 0x10057cf3f v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
10: 0x10054c884 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/usr/local/bin/node]
11: 0x1007d4894 v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
12: 0xc8501a5be3d
jarrodek commented 5 years ago

Hi, Thank you for the issue report. This is the same as https://github.com/mulesoft/api-console/issues/588 I will (eventually) update docs here to include memory setting.

theletterf commented 5 years ago

I'm having the same issue with a 12KB YAML file.

api-console build -n "5.0.0" -t "OAS 3.0" -a openapi.yaml --verbose

Here's the error trace:

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

    0: ExitFrame [pc: 00000138243D0461]
Security context: 0x035d7c31d971 <JSObject>
    1: /* anonymous */ [000000E0FE9BD2C9] [D:\Users\FBenedetti\AppData\Roaming\npm\node_modules\api-console-cli\node_modules\@babel\traverse\lib\index.js:~87] [pc=0000013824C202D7](this=0x02db9812f259 <JSFunction traverse (sfi = 0000018DDC9D0C91)>,0x01c11878e921 <Node map = 0000031134DD0271>,0x0009582d9f61 <Object map = 0000031134D8C161>,0x00448b6143f1 <Sc...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Writing Node.js report to file: report.20190329.155402.12176.001.json
Node.js report completed
 1: 00007FF7CD96CC3A public: __cdecl v8::internal::GCIdleTimeHandler::GCIdleTimeHandler(void) __ptr64+4618
 2: 00007FF7CD9198B6 uv_loop_fork+80934
 3: 00007FF7CD91A411 uv_loop_fork+83841
 4: 00007FF7CDD10F1E void __cdecl v8::internal::FatalProcessOutOfMemory(class v8::internal::Isolate * __ptr64,char const * __ptr64)+798
 5: 00007FF7CDD10E57 void __cdecl v8::internal::FatalProcessOutOfMemory(class v8::internal::Isolate * __ptr64,char const * __ptr64)+599
 6: 00007FF7CDDC0E74 public: static bool __cdecl v8::internal::Heap::RootIsImmortalImmovable(int)+14900
 7: 00007FF7CDDB6994 public: bool __cdecl v8::internal::Heap::CollectGarbage(enum v8::internal::AllocationSpace,enum v8::internal::GarbageCollectionReason,enum v8::GCCallbackFlags) __ptr64+7556
 8: 00007FF7CDDB5068 public: bool __cdecl v8::internal::Heap::CollectGarbage(enum v8::internal::AllocationSpace,enum v8::internal::GarbageCollectionReason,enum v8::GCCallbackFlags) __ptr64+1112
 9: 00007FF7CDDBEAB7 public: static bool __cdecl v8::internal::Heap::RootIsImmortalImmovable(int)+5751
10: 00007FF7CDDBEB36 public: static bool __cdecl v8::internal::Heap::RootIsImmortalImmovable(int)+5878
11: 00007FF7CDF478E1 public: class v8::internal::Handle<class v8::internal::HeapObject> __cdecl v8::internal::Factory::NewFillerObject(int,bool,enum v8::internal::AllocationSpace) __ptr64+49
12: 00007FF7CE000CEA public: static int __cdecl v8::internal::StoreBuffer::StoreBufferOverflow(class v8::internal::Isolate * __ptr64)+27082
13: 00000138243D0461

I'd like to use API-Console, badly, but this issue is ruining the whole experience...

jarrodek commented 5 years ago

Hi, Please, see related issue: https://github.com/mulesoft-labs/api-console-cli/issues/36 for a workaround. This is caused by node's memory limit and how Polymer tools are processing sources to bundle the application. I've reported this issue to the Polymer team but got no response so far.

jarrodek commented 4 years ago

This is now fixed in version 2.0.0.