Merged
XS
Change Breakdown
Testing100%
Race condition fixed in priority queue tests
MA
matt-aitkenEngine priority tests are now fully deterministic, eliminating a race condition where background worker jobs processed partial queue batches out of order.
Engine priority tests are now deterministic and reliable. Previously, a 50ms debounce window allowed background queue jobs to race against sequential test triggers, causing partial queue batches to process out of order. By explicitly disabling the background worker during these specific test runs, the system guarantees that batches process exactly as scheduled without interference. This removes a source of test flakiness in the engine package, providing cleaner and more accurate validation of queue priority logic.
View Original GitHub Description
Summary
- The
processMasterQueueForEnvironmentcall in the priority test was racing against backgroundprocessQueueForWorkerQueuejobs scheduled 50ms after each trigger - With a 50ms debounce (
processWorkerQueueDebounceMs: 50) and runs triggered sequentially, the RunQueue Worker could process those jobs mid-sequence, pushing partial batches to the worker queue in the wrong overall priority order masterQueueConsumersDisabled: trueonly blocks the shard-level polling loops — it does not prevent the RunQueue's own Worker from processing these debounced jobs- Fix: add
worker.disabled: trueto the test 1 engine config, which propagates toworkerOptions.disabledin the RunQueue constructor and prevents the Worker from starting
Test plan
- Both priority tests pass:
pnpm run test ./src/engine/tests/priority.test.ts --run - Test 1 log confirms no
✅ Starting run engine workeror worker loop messages — workers fully disabled - Test 2 unaffected (uses master queue consumers for automatic promotion, no
disabledflag added)
🤖 Generated with Claude Code