Skip to content

fix: embedding-regression test flaky on Windows (EBUSY: resource busy or locked on graph.db) #1353

Description

@carlos-alm

Problem

tests/search/embedding-regression.test.ts intermittently fails on Windows with:

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

The test already has a 3-attempt retry loop in afterAll (added previously) and calls flushDeferredClose() before attempting deletion, but the file lock is not always released in time even with the retry logic.

Evidence

Root Cause

SQLite WAL mode on Windows holds file locks longer than the 3×100ms retry budget allows. The better-sqlite3 db.close() call triggers a WAL checkpoint that can take several hundred milliseconds on Windows.

Fix Direction

Options:

  1. Increase the retry count or delay (e.g., 5 attempts × 200ms)
  2. Use process.on('exit', ...) to defer cleanup to process exit instead of afterAll
  3. Use a retry-based rmSync helper that can wait longer on Windows (up to 2–3s)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    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