Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After many rebuilds, "FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory" #8142

Closed
6 of 7 tasks
JoshuaKGoldberg opened this issue Sep 28, 2022 · 3 comments
Labels
closed: question This issue is a user error/misunderstanding.

Comments

@JoshuaKGoldberg
Copy link
Contributor

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

Consistently when developing on github.com/typescript-eslint/typescript-eslint, after a dozen or two rebuilds, the JavaScript heap runs out of memory:

✔ Client: Compiled successfully in 110.32ms
client (webpack 5.74.0) compiled successfully
ℹ Compiling Client
✔ Client: Compiled successfully in 166.16ms
client (webpack 5.74.0) compiled successfully
ℹ Compiling Client

<--- Last few GCs --->

[95379:0x130048000]  1517409 ms: Mark-sweep (reduce) 4074.8 (4103.0) -> 4012.5 (4039.3) MB, 11.8 / 0.0 ms  (+ 32.0 ms in 1 steps since start of marking, biggest step 32.0 ms, walltime since start of marking 120 ms) (average mu = 0.946, current mu = 0.965)[95379:0x130048000]  1517589 ms: Mark-sweep (reduce) 4158.7 (4184.5) -> 4158.6 (4184.7) MB, 104.5 / 0.0 ms  (average mu = 0.856, current mu = 0.419) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0x1005b7c60 node::Abort() [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
 2: 0x1005b7de8 node::ModifyCodeGenerationFromStrings(v8::Local<v8::Context>, v8::Local<v8::Value>, bool) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
...
82: 0x1053b108c 
error Command failed with signal "SIGABRT".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Full stack trace here
 1: 0x1005b7c60 node::Abort() [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
 2: 0x1005b7de8 node::ModifyCodeGenerationFromStrings(v8::Local<v8::Context>, v8::Local<v8::Value>, bool) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
 3: 0x1006fa350 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
 4: 0x1008a5004 v8::internal::EmbedderStackStateScope::EmbedderStackStateScope(v8::internal::Heap*, v8::internal::EmbedderStackStateScope::Origin, cppgc::EmbedderStackState) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
 5: 0x1008a3ae8 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
 6: 0x100897d90 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
 7: 0x1008985c0 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
 8: 0x10087dcd8 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
 9: 0x100877860 v8::internal::MaybeHandle<v8::internal::SeqOneByteString> v8::internal::FactoryBase<v8::internal::Factory>::NewRawStringWithMap<v8::internal::SeqOneByteString>(int, v8::internal::Map, v8::internal::AllocationType) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
10: 0x100c55e30 v8::internal::IncrementalStringBuilder::Extend() [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
11: 0x1009a9168 v8::internal::JsonStringifier::SerializeString(v8::internal::Handle<v8::internal::String>) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
12: 0x1009ab294 v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize_<false>(v8::internal::Handle<v8::internal::Object>, bool, v8::internal::Handle<v8::internal::Object>) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
13: 0x1009ae5ec v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize_<true>(v8::internal::Handle<v8::internal::Object>, bool, v8::internal::Handle<v8::internal::Object>) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
14: 0x1009ac2d4 v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize_<false>(v8::internal::Handle<v8::internal::Object>, bool, v8::internal::Handle<v8::internal::Object>) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
15: 0x1009a5dec v8::internal::JsonStringify(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
16: 0x100788890 v8::internal::Builtin_JsonStringify(int, unsigned long*, v8::internal::Isolate*) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
17: 0x100f5d18c Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
18: 0x1075ac744 
...
56: 0x1075b2b84 
57: 0x100f7beec Builtins_ArrayMap [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
58: 0x1063a87ac 
59: 0x100f19ef4 Builtins_AsyncFunctionAwaitResolveClosure [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
60: 0x100fa86f8 Builtins_PromiseFulfillReactionJob [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
61: 0x100f0bc4c Builtins_RunMicrotasks [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
62: 0x100ee63a4 Builtins_JSRunMicrotasksEntry [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
63: 0x1008268a4 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
64: 0x100826d94 v8::internal::(anonymous namespace)::InvokeWithTryCatch(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
65: 0x100826f70 v8::internal::Execution::TryRunMicrotasks(v8::internal::Isolate*, v8::internal::MicrotaskQueue*, v8::internal::MaybeHandle<v8::internal::Object>*) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
66: 0x10084d5c8 v8::internal::MicrotaskQueue::RunMicrotasks(v8::internal::Isolate*) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
67: 0x10084de60 v8::internal::MicrotaskQueue::PerformCheckpoint(v8::Isolate*) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
68: 0x100508c4c node::InternalCallbackScope::Close() [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
69: 0x100508fc8 node::InternalMakeCallback(node::Environment*, v8::Local<v8::Object>, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
70: 0x10051d840 node::AsyncWrap::MakeCallback(v8::Local<v8::Function>, int, v8::Local<v8::Value>*) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
71: 0x1005bbfe8 node::fs::FSReqCallback::Reject(v8::Local<v8::Value>) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
72: 0x1005bc7cc node::fs::FSReqAfterScope::Reject(uv_fs_s*) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
73: 0x1005bc8d4 node::fs::AfterNoArgs(uv_fs_s*) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
74: 0x100ec27f8 uv__work_done [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
75: 0x100ec5f94 uv__async_io [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
76: 0x100ed7ce0 uv__io_poll [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
77: 0x100ec6424 uv_run [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
78: 0x1005096d4 node::SpinEventLoop(node::Environment*) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
79: 0x1005f0c30 node::NodeMainInstance::Run(int*, node::Environment*) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
80: 0x1005f0908 node::NodeMainInstance::Run() [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
81: 0x10058bf1c node::Start(int, char**) [/Users/josh/.nvm/versions/node/v18.7.0/bin/node]
82: 0x1053b108c 

Reproducible demo

https://github.com/typescript-eslint.io

Steps to reproduce

  1. git clone https://github.com/typescript-eslint/typescript-eslint
  2. cd typescript-eslint
  3. yarn
  4. yarn start
  5. Make small changes to .md files maybe 10-20 times, allowing a rebuild after each

Expected behavior

Don't crash on me :(

Actual behavior

It crashes.

Note: I don't think this is the same issue as #4765. This is about rebuilds crashing, not performance.

Your environment

This has happened on multiple laptops over the last few months. I've just gotten around to posting now.

Self-service

  • I'd be willing to fix this bug myself.
@JoshuaKGoldberg JoshuaKGoldberg added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Sep 28, 2022
@Josh-Cena
Copy link
Collaborator

I have a feeling this is because of ts-node or some other custom setup instead of Docusaurus itself (at least not directly). No-one else has reported this problem and everyone's rebuilding at least 20 times during development.

@slorber
Copy link
Collaborator

slorber commented Sep 29, 2022

Also the first time I see something like that.

Maybe it could be a memory leak due to something custom, but it would be hard to know hat exactly without investing time profiling it.

For example, one memory leak was reported once writing a custom remark plugin here: #4997

Maybe worth giving it a try: https://engineering.fb.com/2022/09/12/open-source/memlab/

@JoshuaKGoldberg
Copy link
Contributor Author

JoshuaKGoldberg commented Oct 2, 2022

Got it, thanks - I'll move this issue over to typescript-eslint then. Cheers!

Edit: typescript-eslint/typescript-eslint#5718

@Josh-Cena Josh-Cena closed this as not planned Won't fix, can't repro, duplicate, stale Oct 11, 2022
@Josh-Cena Josh-Cena added closed: question This issue is a user error/misunderstanding. and removed bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed: question This issue is a user error/misunderstanding.
Projects
None yet
Development

No branches or pull requests

3 participants