From 5215a9547aea139f36efe6475f01d2a960c87331 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Wed, 3 Jun 2026 12:39:21 +0200 Subject: [PATCH] test: fix flaky webhook E2E test The client Actor exited milliseconds after registering the ad-hoc webhook, so the platform could process the run-succeeded event before the webhook propagated, leaving the server Actor waiting until it timed out. Keep the client run alive briefly after add_webhook to close the race window. --- tests/e2e/test_actor_api_helpers.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/e2e/test_actor_api_helpers.py b/tests/e2e/test_actor_api_helpers.py index 3747dd3b..2bda198d 100644 --- a/tests/e2e/test_actor_api_helpers.py +++ b/tests/e2e/test_actor_api_helpers.py @@ -425,6 +425,8 @@ def do_POST(self) -> None: await Actor.set_value('WEBHOOK_BODY', webhook_body) async def main_client() -> None: + import asyncio + from apify import Webhook, WebhookEventType async with Actor: @@ -438,6 +440,12 @@ async def main_client() -> None: ) ) + # Keep the run alive for a moment after registering the webhook. Without this, the run finishes + # just milliseconds later and the platform may process the run-succeeded event before the freshly + # added ad-hoc webhook has propagated, in which case the webhook never fires and the server Actor + # waits until it times out. + await asyncio.sleep(5) + server_actor, client_actor = await asyncio.gather( make_actor(label='add-webhook-server', main_func=main_server), make_actor(label='add-webhook-client', main_func=main_client),