generator icon indicating copy to clipboard operation
generator copied to clipboard

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

Open michaelhly opened this issue 3 years ago • 6 comments

Describe the bug Trying to generate a typescript client off of the spec here: https://raw.githubusercontent.com/MystenLabs/sui/main/sui/open_rpc/spec/openrpc.json

Heap limit is exceeded even after increasing max memory usage for Node:

export NODE_OPTIONS=--max_old_space_size=16384   
<--- Last few GCs --->

[16933:0x104a08000]   713974 ms: Mark-sweep (reduce) 16381.7 (16406.0) -> 16380.8 (16405.8) MB, 95315.0 / 0.2 ms  (average mu = 0.108, current mu = 0.000) allocation failure scavenge might not succeed
[16933:0x104a08000]   797317 ms: Mark-sweep (reduce) 16381.8 (16402.8) -> 16381.0 (16404.0) MB, 83336.7 / 0.0 ms  (average mu = 0.060, current mu = 0.000) allocation failure scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x101317585 node::Abort() (.cold.1) [/usr/local/bin/node]
 2: 0x1000b25c9 node::Abort() [/usr/local/bin/node]
 3: 0x1000b272f node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 4: 0x1001f6eb7 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 5: 0x1001f6e53 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 6: 0x1003a6eb5 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
 7: 0x1003a897a v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node]
 8: 0x1003a4049 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
 9: 0x1003a18e1 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
10: 0x1003b019a v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
11: 0x1003b0221 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
12: 0x10037d8d2 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/bin/node]
13: 0x1006fdaf8 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
14: 0x100a8adf9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/usr/local/bin/node]
verbose 875.018325764 Error: Command failed with signal "SIGABRT".
    at ProcessTermError.ExtendableBuiltin (/usr/local/lib/node_modules/yarn/lib/cli.js:721:66)
    at ProcessTermError.MessageError (/usr/local/lib/node_modules/yarn/lib/cli.js:750:123)
    at new ProcessTermError (/usr/local/lib/node_modules/yarn/lib/cli.js:790:113)
    at /usr/local/lib/node_modules/yarn/lib/cli.js:34550:30
    at Generator.throw (<anonymous>)
    at step (/usr/local/lib/node_modules/yarn/lib/cli.js:310:30)
    at /usr/local/lib/node_modules/yarn/lib/cli.js:323:13
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
error Command failed with signal "SIGABRT".

To Reproduce

yarn --verbose open-rpc-generator generate -d https://raw.githubusercontent.com/MystenLabs/sui/main/sui/open_rpc/spec/openrpc.json -o ./generated -l typescript -t client -n tsclient

Here is a REPL environment to reproduce the issue: https://replit.com/@MichaelHuang10/FearfulWelloffLeadership#openrpc.json

Expected behavior Generate a typescript client.

Desktop (please complete the following information):

  • OS: macOS
  • Version: Monterey 12.3.1
  • Node: v14.17.1

michaelhly avatar May 08 '22 22:05 michaelhly

Perhaps some validation to prevent this behavior could help?

michaelhly avatar May 09 '22 03:05 michaelhly

hm looks like an issue with a cycle, MoveTypeLayout and TypeTag both ref themselves.

shanejonas avatar May 09 '22 16:05 shanejonas

Thanks @shanejonas ! Should the generator be able to handle cyclic refs? If not, do you know what is the right way/workaround to model this in the schema?

patrickkuo avatar May 12 '22 08:05 patrickkuo

Hello, any progress on this issue?

Looks like the cycle references are not handled correctly

danielvladco avatar Sep 07 '22 11:09 danielvladco

Experiencing the exact same issue with SUI (blockchain)'s openrpc specification. https://gist.github.com/RdeWilde/b6ec9c3c9e0b921d496e4553b5935300

RdeWilde avatar Jun 01 '23 11:06 RdeWilde

Same Issue

tabaktoni avatar Jul 28 '23 13:07 tabaktoni