From 52ae5ba8516ee532ce557ef09b7b3df8026ac2c1 Mon Sep 17 00:00:00 2001 From: abhigyanpatwari Date: Fri, 27 Feb 2026 17:41:06 +0530 Subject: [PATCH] fix: remove unconditional embedder import from disconnect() to prevent crash on Node v24+ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The disconnect() method was unconditionally importing embedder.js on every graceful shutdown, which loads @huggingface/transformers and onnxruntime-node — triggering the exact crash this branch fixes. Since process.exit(0) follows immediately, the OS reclaims all resources without needing disposeEmbedder(). Matches the pattern already established in analyze.ts (lines 318-320). Fixes #89 Co-Authored-By: Claude Opus 4.6 --- gitnexus/src/mcp/local/local-backend.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gitnexus/src/mcp/local/local-backend.ts b/gitnexus/src/mcp/local/local-backend.ts index 99ab22c836..8c721b6466 100644 --- a/gitnexus/src/mcp/local/local-backend.ts +++ b/gitnexus/src/mcp/local/local-backend.ts @@ -1592,8 +1592,11 @@ export class LocalBackend { async disconnect(): Promise { await closeKuzu(); // close all connections - const { disposeEmbedder } = await import('../core/embedder.js'); - await disposeEmbedder(); + // Note: we intentionally do NOT call disposeEmbedder() here. + // ONNX Runtime's native cleanup segfaults on macOS and some Linux configs, + // and importing the embedder module on Node v24+ crashes if onnxruntime + // was never loaded during the session. Since process.exit(0) follows + // immediately after disconnect(), the OS reclaims everything. See #38, #89. this.repos.clear(); this.contextCache.clear(); this.initializedRepos.clear();