[BUG] Claude Crashes while in the middle of the code generation
Environment
- Platform (select one):
- [ ] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI.
- [x] Other: <!-- Personal Laptop MacOS --->
- Claude CLI version: <!-- output of
claude --version--> 1.0.17 - Operating System:
- Terminal:
Bug Description
Steps to Reproduce
Expected Behavior
Actual Behavior
Additional Context
[25512:0x120008000] 122940417 ms: Mark-Compact 3928.5 (4118.6) -> 3913.4 (4119.4) MB, pooled: 0 MB, 179.08 / 0.00 ms (average mu = 0.111, current mu = 0.075) allocation failure; scavenge might not succeed [25512:0x120008000] 122940623 ms: Mark-Compact 3929.8 (4120.4) -> 3912.5 (4118.4) MB, pooled: 2 MB, 188.50 / 0.04 ms (average mu = 0.098, current mu = 0.084) allocation failure; scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory ----- Native stack trace -----
1: 0x105045e2c node::OOMErrorHandler(char const*, v8::OOMDetails const&) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 2: 0x1051f1acc v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 3: 0x1053aeaa0 v8::internal::Heap::CallGCPrologueCallbacks(v8::GCType, v8::GCCallbackFlags, v8::internal::GCTracer::Scope::ScopeId) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 4: 0x1053b4528 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags)::$_1::operator()() const [/opt/homebrew/Cellar/node/23.11.0/bin/node] 5: 0x1053aede4 void heap::base::Stack::SetMarkerAndCallbackImpl<v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags)::$_1>(heap::base::Stack*, void*, void const*) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 6: 0x104f58028 PushAllRegistersAndIterateStack [/opt/homebrew/Cellar/node/23.11.0/bin/node] 7: 0x1053abcd0 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 8: 0x1053a5724 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 9: 0x1053a60ec v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 10: 0x1053971a4 v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 11: 0x105659f10 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 12: 0x104e379f4 Builtins_CEntry_Return1_ArgvOnStack_NoBuiltinExit [/opt/homebrew/Cellar/node/23.11.0/bin/node] 13: 0x104e1aa78 Builtins_SetConstructor [/opt/homebrew/Cellar/node/23.11.0/bin/node] 14: 0x104d9d838 Builtins_JSBuiltinsConstructStub [/opt/homebrew/Cellar/node/23.11.0/bin/node] 15: 0x10e100d84 16: 0x10dc223bc 17: 0x104e6661c Builtins_ArrayMap [/opt/homebrew/Cellar/node/23.11.0/bin/node] 18: 0x10dc1d490 19: 0x10dcbf810 20: 0x10e0542e8 21: 0x10e4da138 22: 0x10dff3a84 23: 0x10e4a06e4 24: 0x10dce5784 25: 0x10df36924 26: 0x10e338e98 27: 0x10df7c7f8 28: 0x104ddde20 Builtins_AsyncFunctionAwaitResolveClosure [/opt/homebrew/Cellar/node/23.11.0/bin/node] 29: 0x104eab298 Builtins_PromiseFulfillReactionJob [/opt/homebrew/Cellar/node/23.11.0/bin/node] 30: 0x104dcd214 Builtins_RunMicrotasks [/opt/homebrew/Cellar/node/23.11.0/bin/node] 31: 0x104d9e3f0 Builtins_JSRunMicrotasksEntry [/opt/homebrew/Cellar/node/23.11.0/bin/node] 32: 0x1053239ec v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 33: 0x105324158 v8::internal::(anonymous namespace)::InvokeWithTryCatch(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 34: 0x10534e6f4 v8::internal::MicrotaskQueue::PerformCheckpointInternal(v8::Isolate*) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 35: 0x104da2978 Builtins_CallApiCallbackGeneric [/opt/homebrew/Cellar/node/23.11.0/bin/node] 36: 0x10dc5253c 37: 0x104d9e50c Builtins_JSEntryTrampoline [/opt/homebrew/Cellar/node/23.11.0/bin/node] 38: 0x104d9e1b0 Builtins_JSEntry [/opt/homebrew/Cellar/node/23.11.0/bin/node] 39: 0x105323a14 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 40: 0x10532337c v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handlev8::internal::Object, v8::internal::Handlev8::internal::Object, int, v8::internal::Handlev8::internal::Object) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 41: 0x1052085f8 v8::Function::Call(v8::Isolate, v8::Localv8::Context, v8::Localv8::Value, int, v8::Localv8::Value) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 42: 0x104f596d8 node::InternalCallbackScope::Close() [/opt/homebrew/Cellar/node/23.11.0/bin/node] 43: 0x104f59b98 node::InternalMakeCallback(node::Environment, v8::Localv8::Object, v8::Localv8::Object, v8::Localv8::Function, int, v8::Localv8::Value, node::async_context, v8::Localv8::Value) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 44: 0x104f71da8 node::AsyncWrap::MakeCallback(v8::Localv8::Function, int, v8::Localv8::Value) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 45: 0x10515f900 node::StreamBase::CallJSOnreadMethod(long, v8::Localv8::ArrayBuffer, unsigned long, node::StreamBase::StreamBaseJSChecks) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 46: 0x10515fb84 node::EmitToJSStreamListener::OnStreamRead(long, uv_buf_t const&) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 47: 0x1051d72c0 node::crypto::TLSWrap::ClearOut() [/opt/homebrew/Cellar/node/23.11.0/bin/node] 48: 0x1051d776c node::crypto::TLSWrap::Cycle() [/opt/homebrew/Cellar/node/23.11.0/bin/node] 49: 0x1051d5d9c node::crypto::TLSWrap::OnStreamRead(long, uv_buf_t const&) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 50: 0x105165f6c node::LibuvStreamWrap::OnUvRead(long, uv_buf_t const*) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 51: 0x105165c74 node::LibuvStreamWrap::ReadStart()::$_1::__invoke(uv_stream_s*, long, uv_buf_t const*) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 52: 0x108d42de4 uv__stream_io [/opt/homebrew/Cellar/libuv/1.51.0/lib/libuv.1.dylib] 53: 0x108d4a06c uv__io_poll [/opt/homebrew/Cellar/libuv/1.51.0/lib/libuv.1.dylib] 54: 0x108d39e08 uv_run [/opt/homebrew/Cellar/libuv/1.51.0/lib/libuv.1.dylib] 55: 0x104f5a48c node::SpinEventLoopInternal(node::Environment*) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 56: 0x10508cf08 node::NodeMainInstance::Run(node::ExitCode*, node::Environment*) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 57: 0x10508cc5c node::NodeMainInstance::Run() [/opt/homebrew/Cellar/node/23.11.0/bin/node] 58: 0x1050048f4 node::Start(int, char**) [/opt/homebrew/Cellar/node/23.11.0/bin/node] 59: 0x1884be0e0 start [/usr/lib/dyld] zsh: abort claude code-metrics-app . -->
Well, this is a heap out of memory error. The app is running out of mem when trying to allocate more space.
You could try something like
export NODE_OPTIONS="--max-old-space-size=4096"
I set it in my ~/.zshrc to
export NODE_OPTIONS="--max-old-space-size=8192"
because yesterday I faced a similar issue and this works good for me.
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.