prefect icon indicating copy to clipboard operation
prefect copied to clipboard

fix: use ephemeral_client_with_lifespan for flaky work queue test

Open zzstoatzz opened this issue 4 months ago • 0 comments

Summary

The test_read_work_queue_runs_does_not_update_a_paused_work_queues_status test was intermittently failing in CI with 503 Service Unavailable errors (e.g., assert 503 == 204).

Root cause: The test was using hosted_api_client which spawns a real uvicorn server subprocess. This introduces race conditions where the server may not be fully ready when the test starts making requests.

Fix: Switch to ephemeral_client_with_lifespan which:

  • Runs in-process (no subprocess)
  • Sets up docket via the lifespan context (required since PyDocket integration)
  • Is more reliable with no subprocess timing issues

Tested locally - passes 5/5 runs consistently.

Context

This was one of several intermittent CI failures we've been investigating. The test was modified in #19377 (PyDocket integration) to use hosted_api_client because the test now requires docket to be running for background tasks. The ephemeral_client_with_lifespan fixture provides the same docket setup without the subprocess reliability issues.

Test plan

  • [x] Verified test passes locally with new fixture
  • [x] Ran test 5 times - all passed
  • [ ] CI passes

🤖 Generated with Claude Code

zzstoatzz avatar Dec 03 '25 17:12 zzstoatzz