Skip to content

🤖 tests: flaky TaskService waitForWorkspaceTurn completion-race test times out under full-suite load #4366

Description

@ThomasK33

Summary

TaskService > waitForWorkspaceTurn handles completion racing with waiter registration (src/node/services/taskService.test.ts) fails intermittently in the full make test-unit run. It fails with:

error: Timed out waiting for workspace turn
      at <anonymous> (src/node/services/workspaceTurnManager.ts:2683:38)
(fail) TaskService > waitForWorkspaceTurn handles completion racing with waiter registration [108.00ms]

Evidence

  1. Full-suite run on 2026-09-23: Bun 1.3.5, Linux x64, BUN_JSC_useWasmIPInt=0, stock GIT_TEMPLATE_DIR. Result: 20,108 pass, 9 skip, 1 fail. This test was the only failure.
  2. The same test passed 3/3 when run in isolation (bun test src/node/services/taskService.test.ts -t "waitForWorkspaceTurn handles completion racing").
  3. The branch where it failed (🤖 feat: let agents discover selectable models with models_list #4346) does not modify taskService.ts or workspaceTurnManager.ts.

Suspected cause (unverified)

The failure took about 100 ms, which suggests the test passes a very short timeoutMs. waitForWorkspaceTurn arms that timer before its asynchronous getWorkspaceTurn read settles. Under full-suite load (event loop and I/O contention), the timer can fire before the completion or record read is observed, so the test measures scheduling latency instead of the race it intends to cover. A deterministic fix would synchronize on the completion/registration signal rather than a wall-clock timeout.

Acceptance

  • The test deterministically exercises the completion-vs-registration race without depending on a short wall-clock timeout.
  • The test is stable under load, for example bun test --rerun-each=50 on the file and a full make test-unit.
  • Product behavior changes only if a real race in waitForWorkspaceTurn is found.

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $255.89

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