Skip to content

Test suite intermittently fails on Windows with 'EBUSY: resource busy or locked' #102

@Zireael

Description

@Zireael

Describe the bug
The test suite intermittently fails on Windows environments with EBUSY: resource busy or locked errors during teardown. This happens when attempting to clean up temporary directories containing SQLite databases using rmSync(dir, { recursive: true, force: true }).

To Reproduce
Run the test suite on a Windows machine. The failures are intermittent but frequent in tests that utilize real OpenCode DB harnesses (e.g., tests dealing with compartments and DB storage).

Root Cause
SQLite file handles take a moment to be fully released by the OS/driver after closing the database connections. Windows, unlike POSIX systems, strictly locks these files and prevents immediate directory deletion.

Workaround/Fix
Wrapping rmSync calls in afterEach hooks with try/catch blocks (to ignore EBUSY) and adding maxRetries: 10 and retryDelay: 100 options allows the handles to release properly and mitigates the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpluginOpenCode plugin (packages/plugin)

    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