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),