Skip to content

Commit ce7de1d

Browse files
committed
Fix flaky LangGraph timeout tests
The test activities slept for 1s with a 100ms start_to_close_timeout. Since Temporal does not actively cancel an activity when start_to_close_timeout fires (it just rejects late completions), the server processing the activity completion raced with it processing the timeout, and on slow runners (Windows CI) the completion sometimes won — causing test_timeout to fail with "DID NOT RAISE WorkflowFailureError". Increase the activity sleep to 30s so the timer reliably fires long before the activity could complete naturally. Worker-shutdown cancellation cleans up the still-sleeping activity when the test exits its `async with Worker(...)` block, so runtime is unchanged. Same fix applied to slow_task, used by the otherwise-identical pattern in test_per_task_activity_options_override.
1 parent f6e113d commit ce7de1d

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

tests/contrib/langgraph/e2e_functional_entrypoints.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ async def interrupt_entrypoint(value: str) -> dict:
134134

135135
@task
136136
async def slow_task(x: int) -> int:
137-
await asyncio.sleep(1)
137+
# Sleep much longer than the start_to_close_timeout used by tests that
138+
# exercise this task's timeout path. Temporal does not actively cancel
139+
# an activity when start_to_close_timeout fires; it just rejects late
140+
# completions, so a short sleep races with the activity completing
141+
# before the server processes the timeout.
142+
await asyncio.sleep(30)
138143
return x
139144

140145

tests/contrib/langgraph/test_timeout.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ class State(TypedDict):
1919

2020

2121
async def node(state: State) -> dict[str, str]: # pyright: ignore[reportUnusedParameter]
22-
await sleep(1) # 1 second
22+
# Sleep much longer than the start_to_close_timeout below: Temporal does
23+
# not actively cancel an activity when start_to_close_timeout fires, it
24+
# just rejects late completions. A short sleep races with the server
25+
# processing the completion vs. the timeout, which flakes on slow CI.
26+
await sleep(30)
2327
return {"value": "done"}
2428

2529

0 commit comments

Comments
 (0)