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.

chore(tasks): fix flaky background heartbeat test on fresh runners (#106551)

Rossf844a6176179
diff --git a/products/tasks/backend/temporal/process_task/activities/tests/test_relay_sandbox_events.py b/products/tasks/backend/temporal/process_task/activities/tests/test_relay_sandbox_events.py
index ca19a756ca2d..3687ff0804cb 100644
--- a/products/tasks/backend/temporal/process_task/activities/tests/test_relay_sandbox_events.py
+++ b/products/tasks/backend/temporal/process_task/activities/tests/test_relay_sandbox_events.py
@@ -1720,7 +1720,9 @@ class TestBackgroundHeartbeat:
_background_heartbeat(
stop_event,
cast(temporalio.client.WorkflowHandle, handle),
- [time.monotonic() - 100.0],
+ # The gate reads a value <= 0 as "no event yet". monotonic() counts from boot,
+ # so subtracting an offset gives <= 0 on a runner that booted recently.
+ [time.monotonic()],
[0.0],
[False],
inactivity_timeout_seconds=3600.0,