Fix flaky LangGraph timeout tests#1495
Merged
tconley1428 merged 7 commits intomainfrom May 1, 2026
Merged
Conversation
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.
brianstrauch
approved these changes
Apr 30, 2026
Replaces the 30s sleep with await asyncio.Event().wait() to make the intent explicit: the activity has no natural exit, so it can only end via the start_to_close_timeout firing or worker-shutdown cancellation.
The function never sleeps anymore — it waits on an Event() that's never set — so "slow" was misleading. waiting_task names what it actually does.
Sushisource
approved these changes
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tests/contrib/langgraph/test_timeout.pyslept for 1s with a 100msstart_to_close_timeout. Temporal does not actively cancel an activity whenstart_to_close_timeoutfires — it just rejects late completions — so the server processing the activity completion raced with it processing the timeout. On slow runners (Windows CI) the completion sometimes won, causingtest_timeoutto fail withFailed: DID NOT RAISE WorkflowFailureError(e.g. this run).await asyncio.Event().wait()so the activity has no natural exit at all — the only way out is thestart_to_close_timeoutfiring or worker-shutdown cancellation when the test exits itsasync with Worker(...)block. Test runtime is unchanged (~1.3s locally).test_per_task_activity_options_override, which had the identical pattern. Renamed it fromslow_tasktowaiting_tasksince it no longer sleeps.Test plan
uv run pytest tests/contrib/langgraph/test_timeout.py— passes consistently across multiple local runsuv run pytest tests/contrib/langgraph/test_e2e_functional.py::TestFunctionalAPIPerTaskOptions— passes