Skip to content

memory_search crashes gateway: node-llama-cpp FileHandle GC error on Node.js 25 #18839

Description

@TrevorHinesley

Bug Report

Summary

memory_search tool call causes an uncaught exception that freezes the agent run and makes the gateway unresponsive. /restart (SIGUSR1) cannot recover — requires manual gateway process restart.

Environment

  • OpenClaw version: 2026.2.15
  • Node.js: v25.4.0
  • OS: macOS (Darwin 23.6.0, arm64)
  • Memory provider: local (node-llama-cpp + embeddinggemma-300M)
  • Channel: Telegram

Error

[openclaw] Uncaught exception: Error: A FileHandle object was closed during garbage collection.
This used to be allowed with a deprecation warning but is now considered an error.
Please close FileHandle objects explicitly.
File descriptor: 58 (~/.node-llama-cpp/models/hf_ggml-org_embeddinggemma-300m-qat-Q8_0.gguf.ipull)

Steps to Reproduce

  1. Configure local memory search provider (node-llama-cpp with embeddinggemma-300M)
  2. Run on Node.js 25.x
  3. Trigger memory_search tool call
  4. The embedding model file handle gets garbage collected instead of being explicitly closed
  5. Node.js 25 throws a hard error (previously a deprecation warning in earlier Node versions)

Impact

  • Agent run freezes mid-tool-call with no response to user
  • /restart fails — logs show abort failed: reason=no_active_run suggesting the run is in a zombie state
  • Requires manual gateway restart (SSH into host, restart process)
  • User experienced ~7 minutes of unresponsiveness before manually intervening

Relevant Log Lines

// memory_search tool starts
{"subsystem":"agent/embedded"} embedded run tool start: tool=memory_search

// Embedding batches running
{"subsystem":"memory"} memory embeddings: batch start (items=1, timeoutMs=600000)
{"subsystem":"memory"} memory embeddings: batch start (items=1, timeoutMs=600000)
{"subsystem":"memory"} memory embeddings: batch start (items=1, timeoutMs=600000)
{"subsystem":"memory"} memory embeddings: batch start (items=4, timeoutMs=600000)

// CRASH — FileHandle GC error
[openclaw] Uncaught exception: Error: A FileHandle object was closed during garbage collection...

// Later: /stop and /restart commands fail to abort
{"subsystem":"diagnostic"} abort failed: sessionId=... reason=no_active_run

Expected Behavior

  • node-llama-cpp should explicitly close file handles instead of relying on GC
  • If a tool call throws an uncaught exception, the gateway should recover gracefully
  • /restart should be able to kill zombie agent runs

Suggested Fixes

  1. Immediate: Ensure node-llama-cpp file handles are explicitly closed after embedding operations
  2. Defensive: Wrap memory_search tool execution in try/catch so uncaught exceptions don't freeze the gateway
  3. Recovery: /restart should force-kill any in-progress agent runs regardless of state

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions