mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-10 03:27:59 +00:00
fix(embeddings): dispose ONNX Runtime session before process exit
The ONNX Runtime inference session was never disposed after the embedding pipeline completed. When process.exit(0) fires, both ONNX Runtime's and LadybugDB's C++ atexit destructors run and race with each other, causing "mutex lock failed: Invalid argument" crashes. Add disposeEmbedder() call after embedding pipeline completes to properly release the ONNX session before LadybugDB closes and before process.exit(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c72890d59d
commit
ddbfa838ca
2 changed files with 11 additions and 0 deletions
|
|
@ -290,5 +290,7 @@ export const analyzeCommand = async (inputPath?: string, options?: AnalyzeOption
|
|||
// LadybugDB's native module holds open handles that prevent Node from exiting.
|
||||
// ONNX Runtime also registers native atexit hooks that segfault on some
|
||||
// platforms (#38, #40). Force-exit to ensure clean termination.
|
||||
// The ONNX session is disposed in runFullAnalysis after embeddings complete
|
||||
// to prevent C++ atexit destructors from racing with closed DB handles.
|
||||
process.exit(0);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -265,6 +265,15 @@ export async function runFullAnalysis(
|
|||
{},
|
||||
cachedEmbeddingNodeIds.size > 0 ? cachedEmbeddingNodeIds : undefined,
|
||||
);
|
||||
|
||||
// Release ONNX Runtime session to prevent its C++ atexit handlers from
|
||||
// racing with LadybugDB cleanup during process.exit() (#38, #40).
|
||||
try {
|
||||
const { disposeEmbedder } = await import('./embeddings/embedder.js');
|
||||
await disposeEmbedder();
|
||||
} catch {
|
||||
/* best-effort */
|
||||
}
|
||||
}
|
||||
|
||||
// ── Phase 5: Finalize (98–100%) ───────────────────────────────────
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue