fix(tests): close three integration-test races that flaked CI

Merged
WA
2d ago
+25-8

Summary

  • lane.integration.ts "finishes an occurrence whose Sim process died mid-run": waits until the first leg's text is persisted to the stream buffer before killing the process. Killing on worker.open alone raced the persist, so the takeover reattached with no text and the summary lost its first leg (the unattended suite already waits this way)

  • 0037_seal_account_tokens.integration.ts: the cancelled migration run's rejection is handled the moment it starts, not after the pg_cancel_backend loop, so a cancel that lands first no longer fails the shard as an unhandled rejection while every test passes

  • search-source-setup.integration.ts: same fix for the refused provider expansion awaited after the concurrent grant

  • CI: the integration Postgres now logs lock waits (1s) and statements over 20s. One remaining flake (dispatcher.integration.ts) hangs on a lock that the current logs can't attribute; the next occurrence will name the waiter, the lock and the blocking statement

Found by ranking every failed integration job in ci.yml over the last two weeks; each of these failed on unrelated branches with passing reruns.

Type of Change

  • Bug fix (tests)

Testing

  • Each race injected deterministically (local-only delay): original test red with the same failure CI showed, fixed test green with and without the delay
  • bun run test:integration lane.integration.ts search-source-setup.integration.ts; the 0037 file against its own Postgres container
  • biome on the touched files
  • The CI settings command run against a scratch Postgres 17: all three settings applied

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)