Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(batch-exports): increase wait_for_workflows timeout and use exponential backoff (#64288)

mendral-app[bot]e459f6c53868
diff --git a/products/batch_exports/backend/tests/temporal/backfills/conftest.py b/products/batch_exports/backend/tests/temporal/backfills/conftest.py
index 6b3cddb1d33d..64b52c16cffd 100644
--- a/products/batch_exports/backend/tests/temporal/backfills/conftest.py
+++ b/products/batch_exports/backend/tests/temporal/backfills/conftest.py
@@ -13,22 +13,24 @@ async def wait_for_workflows(
temporal_client: temporalio.client.Client,
schedule_id: str,
expected_count: int,
- timeout: int = 30,
+ timeout: int = 60,
) -> list[temporalio.client.WorkflowExecution]:
"""Wait for workflows to be queryable and return them."""
query = f'TemporalScheduledById="{schedule_id}" order by StartTime asc'
workflows: list[temporalio.client.WorkflowExecution] = []
- waited = 0
+ elapsed = 0.0
+ delay = 0.5
while len(workflows) < expected_count:
- waited += 1
- if waited > timeout:
+ if elapsed > timeout:
raise TimeoutError(
f"Timed-out waiting for workflows for schedule {schedule_id} to be query-able. "
f"Found {len(workflows)} workflows, expected {expected_count}"
)
- await asyncio.sleep(1)
+ await asyncio.sleep(delay)
+ elapsed += delay
+ delay = min(delay * 2, 5)
workflows = [workflow async for workflow in temporal_client.list_workflows(query=query)]
assert len(workflows) == expected_count