fix: remove unconditional embedder import from disconnect() to prevent crash on Node v24+

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 <noreply@anthropic.com>
This commit is contained in:
abhigyanpatwari 2026-02-27 17:41:06 +05:30
parent 0f91e943e7
commit 52ae5ba851

View file

@ -1592,8 +1592,11 @@ export class LocalBackend {
async disconnect(): Promise<void> {
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();