Skip to content

fix(ci): Windows EBUSY flaky test in embedding-regression.test.ts #1344

@carlos-alm

Description

@carlos-alm

Problem

The Windows CI job Test Node 22 (windows-latest) intermittently fails with:

Error: EBUSY: resource busy or locked, unlink 'C:\Users\RUNNER~1\AppData\Local\Temp\codegraph-embed-regression-NBNEYq\.codegraph\graph.db'

Observed in run 27049716531 triggered by PR #1338 (docs-only change). This is unrelated to the PR contents — it's a pre-existing Windows file-locking race in the test cleanup.

Root cause

tests/search/embedding-regression.test.ts creates a temp directory with a SQLite DB (graph.db) and tries to unlink it on cleanup. On Windows, SQLite holds an exclusive file lock via the WAL journal until the connection is fully closed. If better-sqlite3 hasn't fully flushed/closed the DB handle before the temp-dir cleanup runs, the unlink fails with EBUSY.

Main branch CI passes (all three recent runs green), so this is a non-deterministic race in the test teardown.

Fix

Add an explicit db.close() call before the temp directory cleanup in the test's afterAll / afterEach hook, or add a short retry loop on the unlink with exponential backoff (Windows-specific workaround pattern).

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions