From ebc1a28545ec8037d74f7bd16ec20d45df5ed836 Mon Sep 17 00:00:00 2001 From: Alex Mazzeo Date: Wed, 5 Aug 2026 14:22:01 -0700 Subject: [PATCH] Fix race in nexus double start test --- tests/nexus/test_temporal_operation.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/nexus/test_temporal_operation.py b/tests/nexus/test_temporal_operation.py index d966c5cc6..98a58ed71 100644 --- a/tests/nexus/test_temporal_operation.py +++ b/tests/nexus/test_temporal_operation.py @@ -336,19 +336,21 @@ async def double_start_activity( self, _ctx: nexus.TemporalStartOperationContext, client: nexus.TemporalNexusClient, - input: Input, + _input: Input, ) -> nexus.TemporalOperationResult[None]: + # Keep the first activity running so its callback cannot race the + # handler error raised by the second start. await client.start_activity( - echo_activity, - input, + wait_for_cancel_activity, id=f"double-start-activity-{uuid.uuid4()}", - start_to_close_timeout=timedelta(seconds=5), + start_to_close_timeout=timedelta(seconds=30), + heartbeat_timeout=timedelta(seconds=1), ) await client.start_activity( - echo_activity, - input, + wait_for_cancel_activity, id=f"double-start-activity-{uuid.uuid4()}", - start_to_close_timeout=timedelta(seconds=5), + start_to_close_timeout=timedelta(seconds=30), + heartbeat_timeout=timedelta(seconds=1), ) return nexus.TemporalOperationResult.sync(None) @@ -1264,7 +1266,7 @@ async def test_temporal_operation_double_start_activity_raises_handler_err( env.client, task_queue=task_queue, nexus_service_handlers=[TestServiceHandler()], - activities=[echo_activity], + activities=[wait_for_cancel_activity], ): nexus_client = client.create_nexus_client(TestService, endpoint_name)