Skip to content

Commit 89f8f70

Browse files
committed
fix(test): flush deferred DB close before temp-dir removal in embedding regression (#1328)
On Windows, buildGraph uses closeDbDeferred which schedules the SQLite WAL checkpoint via setImmediate. When afterAll runs before the deferred close executes, fs.rmSync throws EBUSY on graph.db. Call flushDeferredClose before the temp-dir cleanup to ensure the handle is closed synchronously.
1 parent 818a557 commit 89f8f70

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

tests/search/embedding-regression.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import os from 'node:os';
1111
import path from 'node:path';
1212
import Database from 'better-sqlite3';
1313
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
14+
import { flushDeferredClose } from '../../src/db/connection.js';
1415

1516
// Detect whether transformers is available (optional dep)
1617
let hasTransformers = false;
@@ -81,6 +82,10 @@ describe.skipIf(!hasTransformers)('embedding regression (real model)', () => {
8182
}, 240_000);
8283

8384
afterAll(() => {
85+
// Flush any deferred DB close handles before removing the temp dir.
86+
// On Windows, SQLite WAL files are held open by the setImmediate-deferred
87+
// close path, causing EBUSY when fs.rmSync tries to unlink graph.db.
88+
flushDeferredClose();
8489
if (tmpDir) fs.rmSync(tmpDir, { recursive: true, force: true });
8590
});
8691

0 commit comments

Comments
 (0)