Skip to content

test(desktop): exact-selection Project test races on add order and fails cleanup on Windows #5834

Closed

Description

@liugddx

apps/desktop/src/main/__tests__/project-management-service.test.ts › "add preserves the exact selected directory inside an existing repository" became nondeterministic in #5786, and it fails on every run on Windows.

Failure 1: selection order races (all platforms)

The test now runs await Promise.all([service.add(), service.add()]) and then asserts that setSelection was called in the order repository, then nested. setSelection fires when each add() settles, so the order depends on which call finishes first.

CI failure on #5832 (unrelated change, Linux):

+   '/tmp/.../repository/nested',
      '/tmp/.../repository',
-   '/tmp/.../repository/nested'

Repro: delay the first chooseDirectory resolution by 50 ms, and the test fails every time.

Failure 2: EBUSY during cleanup (Windows)

t.after(() => rm(base)) is registered before t.after(() => catalog.close()). after hooks run in registration order, so the directory is removed while runtime.sqlite is still open:

EBUSY: resource busy or locked, unlink '...\maka-project-exact-selection-XXXX\storage\runtime.sqlite'

This happens 30 times out of 30 locally on Windows. Linux doesn't notice, because it can unlink open files.

Fix

Add the Projects sequentially, as the test did before #5786; the test is about exact directory selection, not concurrency. Close the catalog, then remove the directory, in a single hook.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions