fix(edge-worker): await worker startup in integration tests - #680
Conversation
startWorker() fired worker.startOnlyOnce() fire-and-forget, so the startup transaction (ensure_flow_compiled: create_flow/add_step, or destructive local recompile via delete_flow_and_data) raced the test body and could commit across test boundaries, interleaving with the next test's reset_db. A stray commit then left a listed PGMQ queue with no owning flow row, and the next create_flow correctly rejected it: cannot create flow "X": queue "X" is already in use by another owner. Fix: make startWorker() async and await startup; await all 31 call sites and performanceMapFlow's startWorkers. Startup errors now fail at the call site instead of surfacing via a later worker.stop(). Product code, SQL, and migrations are untouched; the ownership guard stays as approved in #650. mapFlow.test.ts focused runs pass twice consecutively; full integration suite 63 passed, 0 failed. Refs #650. CI: edge-worker-integration on PR #679.
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
View your CI Pipeline Execution ↗ for commit cae4772
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
|
View your CI Pipeline Execution ↗ for commit cae4772
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |

Summary
Make the integration-test harness await worker startup.
startWorker()inpkgs/edge-worker/tests/integration/_helpers.tsfiredworker.startOnlyOnce()fire-and-forget, so the startup transaction (ensure_flow_compiled:create_flow/add_step, or destructive local recompile viadelete_flow_and_data) could race the test body and commit across test boundaries, interleaving with the next test'sreset_db. A stray commit then left a listed PGMQ queue with no owning flow row, and a latercreate_flowrejected it (queue "X" is already in use by another owner). Startup errors now fail at the call site instead of surfacing via a laterworker.stop().Test-only change:
_helpers.ts, 31 call sites across 9 integration test files, andperformanceMapFlow'sstartWorkers. No product code, SQL, or migrations.Base of the #679 stack (queue identity feature); that PR's CI originally failed on this race.
Checks
mapFlow.test.tsfocused runs pass twice consecutively (no orphan-queue leak across runs);queueIdentity.test.tslikewisepnpm nx test:integration edge-worker: 63 passed, 0 failednx affected --target=prepush: 32/32 successfulPart of #650