ruvnet / ruvnet/ruflo

FATAL OOM → better-sqlite3 “database connection is not open” at session-manager.js:642 (macOS ARM, Node 23.3.0)

Open
#569 5 comments 1 reaction 1 assignee Claimed by @ruvnet View on GitHub
already-fixed
Dominant language
TypeScript
Stars
72.7k
Forks
8.6k
Avg merge
2d 23h
Merged PRs (30d)
83

Description

### Summary
Running `claude-flow` hits a V8 out-of-memory error. During shutdown, the app attempts to log a session event and `better-sqlite3` throws `TypeError: The database connection is not open` (likely after the DB handle is closed or never opened due to the crash).

### Error output

```
<--- Last few GCs --->

[44225:0x118008000] 253638 ms: Scavenge (reduce) (interleaved) 4088.3 (4099.4) -> 4085.9 (4094.1) MB, pooled: 0 MB, 4.79 / 0.00 ms (average mu = 0.200, current mu = 0.193) allocation failure;
[44225:0x118008000] 254365 ms: Mark-Compact (reduce) 4086.2 (4094.1) -> 4085.3 (4093.9) MB, pooled: 0 MB, 709.54 / 0.00 ms (+ 152.4 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 881 ms) (average mu = 0.165,

<--- JS stacktrace --->

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

1: 0x10456f768 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
2: 0x104717b64 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
3: 0x104717b18 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
4: 0x1048d5638 v8::internal::Heap::CallGCPrologueCallbacks(v8::GCType, v8::GCCallbackFlags, v8::internal::GCTracer::Scope::ScopeId) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
5: 0x1048d733c v8::internal::Heap::DevToolsTraceEventScope::~DevToolsTraceEventScope() [/opt/homebrew/Cellar/node/23.3.0/bin/node]
6: 0x1048d5d00 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags)::$_1::operator()() const [/opt/homebrew/Cellar/node/23.3.0/bin/node]
7: 0x1048d59b0 void heap::base::Stack::SetMarkerAndCallbackImpl(heap::base::Stack*, void*, void const*) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
8: 0x104480028 PushAllRegistersAndIterateStack [/opt/homebrew/Cellar/node/23.3.0/bin/node]
9: 0x1048d3f54 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
10: 0x104861d9c v8::internal::StackGuard::HandleInterrupts(v8::internal::StackGuard::InterruptLevel) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
11: 0x104bd9d84 v8::internal::Runtime_StackGuardWithGap(int, unsigned long*, v8::internal::Isolate*) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
12: 0x10435f9f4 Builtins_CEntry_Return1_ArgvOnStack_NoBuiltinExit [/opt/homebrew/Cellar/node/23.3.0/bin/node]
13: 0x1305a5f0c
14: 0x130ad3d9c
15: 0x130965c88
16: 0x130b789e0
17: 0x1305c2b08
18: 0x1305c2208
19: 0x130b29da0
20: 0x130ad6664
21: 0x130667014
22: 0x130b144c8
23: 0x104305e20 Builtins_AsyncFunctionAwaitResolveClosure [/opt/homebrew/Cellar/node/23.3.0/bin/node]
24: 0x1043d3298 Builtins_PromiseFulfillReactionJob [/opt/homebrew/Cellar/node/23.3.0/bin/node]
25: 0x1042f5214 Builtins_RunMicrotasks [/opt/homebrew/Cellar/node/23.3.0/bin/node]
26: 0x1042c63f0 Builtins_JSRunMicrotasksEntry [/opt/homebrew/Cellar/node/23.3.0/bin/node]
27: 0x10483a410 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
28: 0x10483aae0 v8::internal::(anonymous namespace)::InvokeWithTryCatch(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
29: 0x10485fbcc v8::internal::MicrotaskQueue::RunMicrotasks(v8::internal::Isolate*) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
30: 0x10485f95c v8::internal::MicrotaskQueue::PerformCheckpointInternal(v8::Isolate*) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
31: 0x1042caaac Builtins_CallApiCallbackOptimizedNoProfiling [/opt/homebrew/Cellar/node/23.3.0/bin/node]
32: 0x1307c575c
33: 0x1042c650c Builtins_JSEntryTrampoline [/opt/homebrew/Cellar/node/23.3.0/bin/node]
34: 0x1042c61b0 Builtins_JSEntry [/opt/homebrew/Cellar/node/23.3.0/bin/node]
35: 0x10483a438 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
36: 0x104839d98 v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle, v8::internal::Handle, int, v8::internal::Handle*) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
37: 0x10472a830 v8::Function::Call(v8::Isolate*, v8::Local, v8::Local, int, v8::Local*) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
38: 0x1044816d4 node::InternalCallbackScope::Close() [/opt/homebrew/Cellar/node/23.3.0/bin/node]
39: 0x104481b94 node::InternalMakeCallback(node::Environment*, v8::Local, v8::Local, v8::Local, int, v8::Local*, node::async_context, v8::Local) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
40: 0x104499b54 node::AsyncWrap::MakeCallback(v8::Local, int, v8::Local*) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
41: 0x1046740d0 node::StreamBase::CallJSOnreadMethod(long, v8::Local, unsigned long, node::StreamBase::StreamBaseJSChecks) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
42: 0x104674354 node::EmitToJSStreamListener::OnStreamRead(long, uv_buf_t const&) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
43: 0x10467a8a8 node::LibuvStreamWrap::OnUvRead(long, uv_buf_t const*) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
44: 0x10467a5b0 node::LibuvStreamWrap::ReadStart()::$_1::__invoke(uv_stream_s*, long, uv_buf_t const*) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
45: 0x108cff074 uv__stream_io [/opt/homebrew/Cellar/libuv/1.49.2/lib/libuv.1.dylib]
46: 0x108d06114 uv__io_poll [/opt/homebrew/Cellar/libuv/1.49.2/lib/libuv.1.dylib]
47: 0x108cf6184 uv_run [/opt/homebrew/Cellar/libuv/1.49.2/lib/libuv.1.dylib]
48: 0x104482488 node::SpinEventLoopInternal(node::Environment*) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
49: 0x1045ba2c0 node::NodeMainInstance::Run(node::ExitCode*, node::Environment*) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
50: 0x1045ba014 node::NodeMainInstance::Run() [/opt/homebrew/Cellar/node/23.3.0/bin/node]
51: 0x10452fce8 node::Start(int, char**) [/opt/homebrew/Cellar/node/23.3.0/bin/node]
52: 0x18a0e0274 start [/usr/lib/dyld]
/opt/homebrew/lib/node_modules/claude-flow/node_modules/better-sqlite3/lib/methods/wrappers.js:5
return this[cppdb].prepare(sql, this, false);
^

TypeError: The database connection is not open
at Database.prepare (/opt/homebrew/lib/node_modules/claude-flow/node_modules/better-sqlite3/lib/methods/wrappers.js:5:21)
at HiveMindSessionManager.logSessionEvent (file:///opt/homebrew/lib/node_modules/claude-flow/src/cli/simple-commands/hive-mind/session-manager.js:642:28)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

Node.js v23.3.0
```

### Where it happens
- File: `src/cli/simple-commands/hive-mind/session-manager.js`
- Line: ~642 (`logSessionEvent` calling `db.prepare(...)`)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.