fix(embeddings): also dispose ONNX session on error path

If the embedding pipeline throws mid-run, the outer catch block
only closed LadybugDB but left the ONNX Runtime session alive.
Dispose it before closeLbug to prevent the same atexit race on
the error path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
jreakin 2026-03-31 23:42:53 -05:00
parent ddbfa838ca
commit 82035d6b6a

View file

@ -354,7 +354,14 @@ export async function runFullAnalysis(
pipelineResult,
};
} catch (err) {
// Ensure LadybugDB is closed even on error
// Ensure native resources are closed even on error to prevent
// C++ atexit destructor races during process.exit() (#38, #40).
try {
const { disposeEmbedder } = await import('./embeddings/embedder.js');
await disposeEmbedder();
} catch {
/* swallow */
}
try {
await closeLbug();
} catch {