Redocly / Redocly/redoc

Build-docs fails with heap allocation failure.

Open
#2,474 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Bug
Dominant language
TypeScript
Stars
25.9k
Forks
2.4k
Avg merge
13h 10m
Merged PRs (30d)
4

Description

Describe the bug
Any attempt at rendering the below referenced .yaml to .html via build-docs (or previewing via preview-docs) results in the following error:
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

To Reproduce
Steps to reproduce the behavior:

  1. Given this academics.yaml file.
  2. Run this command with these arguments... npx @redocly/cli build-docs academics.yaml
  3. See FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory error

Expected behavior
Expect the file to correctly render.

Logs

<--- Last few GCs --->

[3349:0x7ff3a522b000] 32432 ms: Scavenge 4046.5 (4127.0) -> 4043.5 (4128.2) MB, 7.9 / 0.0 ms (average mu = 0.444, current mu = 0.329) allocation failure;
[3349:0x7ff3a522b000] 32453 ms: Scavenge 4047.9 (4128.2) -> 4045.5 (4131.7) MB, 9.6 / 0.0 ms (average mu = 0.444, current mu = 0.329) allocation failure;
[3349:0x7ff3a522b000] 33511 ms: Scavenge 4051.0 (4131.7) -> 4048.2 (4149.2) MB, 1048.3 / 0.0 ms (average mu = 0.444, current mu = 0.329) allocation failure;

<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
1: 0x10dc8f8b5 node::Abort() (.cold.1) [/Users/moneil/.nvm/versions/node/v18.7.0/bin/node]
2: 0x10c761ab9 node::Abort() [/Users/moneil/.nvm/versions/node/v18.7.0/bin/node]
3: 0x10c761c2f node::OnFatalError(char const*, char const*) [/Users/moneil/.nvm/versions/node/v18.7.0/bin/node]
4: 0x10c8d7f77 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/moneil/.nvm/versions/node/v18.7.0/bin/node]
5: 0x10caa08b5 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users/moneil/.nvm/versions/node/v18.7.0/bin/node]
6: 0x10ca9f292 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/moneil/.nvm/versions/node/v18.7.0/bin/node]
7: 0x10ca915ca v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/moneil/.nvm/versions/node/v18.7.0/bin/node]
8: 0x10ca91f45 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/moneil/.nvm/versions/node/v18.7.0/bin/node]
9: 0x10ca743be v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/Users/moneil/.nvm/versions/node/v18.7.0/bin/node]
10: 0x10ceaa5fc v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/Users/moneil/.nvm/versions/node/v18.7.0/bin/node]
11: 0x10d2a4bf9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/Users/moneil/.nvm/versions/node/v18.7.0/bin/node]
12: 0x10d28d259 Builtins_SetConstructor [/Users/moneil/.nvm/versions/node/v18.7.0/bin/node]
13: 0x10d22678c Builtins_JSBuiltinsConstructStub [/Users/moneil/.nvm/versions/node/v18.7.0/bin/node]
14: 0x111cecaa0
15: 0x111ced899
Abort trap: 6

OpenAPI definition
academics.yaml, OpenAPI 3.0.3, 68789 lines, with 2437 $refs.

Redocly Version(s)
$ npx @redocly/cli --version
1.0.0-beta.126

Node.js Version(s)
$ node --version
v18.7.0

Additional context
Increasing Node heap via ENV had no effect.
e.g.: $ export NODE_OPTIONS="--max-old-space-size=12288"

<--- Last few GCs --->

[60612:0x7ff29992b000] 342252 ms: Mark-sweep 12093.2 (12320.7) -> 12086.8 (12330.5) MB, 41143.5 / 0.0 ms (average mu = 0.312, current mu = 0.034) allocation failure; scavenge might not succeed
[60612:0x7ff29992b000] 436763 ms: Mark-sweep 12102.7 (12330.5) -> 12094.5 (12337.5) MB, 94340.8 / 0.0 ms (average mu = 0.103, current mu = 0.002) allocation failure; scavenge might not succeed

<--- JS stacktrace --->
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

$ npx @redocly/cli stats academics.yaml
Document: academics.yaml stats:

🚗 References: 1306
📦 External Documents: 0
📈 Schemas: 1306
👉 Parameters: 0
🔗 Links: 0
➡️ Path Items: 171
👷 Operations: 171
🔖 Tags: 17

$ npx @redocly/cli lint academics.yaml
Woohoo! Your OpenAPI definition is valid.

Aside from causing demo GitHub pages rendering to fail tests, this prevents the building of the html to deliver via ci/cd workflows.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no source file or test. Start by reproducing the failure with build-docs and preview-docs using academics.yaml, then trace the rendering path; done means the 68,789-line OpenAPI document renders successfully without a heap allocation failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, openapi, typescript
Domain
cli, documentation, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.