Repository navigation
test(auth): replace 50ms deletion-race deadlines with a settle check - #7846
Conversation
Two deletion-race tests held post-commit side effects, slept 50ms, and asserted deletion had already settled. Deletion runs several real Postgres transactions, so a slow CI runner failed the assertion even though deletion was never blocked (main run 36850679984). Await deletion with the file's 5s within() deadline while the side effects are still held, releasing them in finally. A deletion that does wait on post-commit work still fails, with "race did not settle". Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — test-only change, no blocking or medium findings.
This PR modifies a single integration test file (server/tests/integration/workos-user-deletion-race.test.ts), replacing a brittle deletionSettled flag + fixed 50ms sleep with a timeout-bounded await within(deleteIdentityCredential(...)) and releasing held side effects in a finally. The "deletion does not block on held post-commit side effects" invariant is preserved via within's 5s deadline, with post-settle assertions intact.
No production, schema, docs, dist, or changeset surface is touched. No Critical/High/Medium findings reported.
Gate checks: no no-auto-approve team match; gated_paths is false; high_risk is false. review_decision is REVIEW_REQUIRED, but row 2 only applies when gated_paths is true — it is false here, so no escalation is triggered. With zero findings, rows 1–8 do not fire; falls through to row 9 → approve.
Summary
Fixes a flaky integration test that failed on
mainafter #7832 merged (run 36850679984, passed on re-run):Two tests hold a webhook's post-commit side effects open, start a credential deletion, sleep 50ms, and assert deletion has already settled. Deletion runs several real Postgres transactions, so on a slow runner it can take longer than 50ms. The test then fails even though deletion was never blocked. The WorkOS calls in this file are already in-process mocks, so WorkOS latency isn't involved.
Change
Test file only. Both tests now await deletion with the file's existing
within()helper (5s deadline) while the side effects are still held, and release them infinally:race did not settle within 5000msinstead of hanging.The third 50ms check in this file (line ~887) asserts the opposite: that deletion is blocked by an in-flight writer. A slow runner can't make it fail spuriously, so it's left unchanged.
Verification
Run locally against Postgres 16 provisioned with the same steps as
build-check.yml(evaluator roles, migrations 584/585 applied as the operator role). To simulate a slow runner, the Postgres container was CPU-limited withdocker update --cpus:I also made deletion wait on the held side effects, to check the test still catches the real bug. The fixed test fails with
race did not settle within 5000msand doesn't hang.Not in scope: at an extreme 0.05 CPU,
bounds concurrent guarded writers below deletion-reserved pool capacityhits the productionCREDENTIAL_MUTATION_ADMISSION_TIMEOUT_MSinidentity-db.ts. That timeout is real application behavior under a roughly 20× slower database, and it hasn't been seen in CI, so it's left alone.🤖 Generated with Claude Code
Open workspace in Conductor