Skip to content

Fix swallowed CancelledError in start_child_workflow and Nexus operations (Issue #1445)#1472

Open
yegorske50 wants to merge 2 commits intotemporalio:mainfrom
yegorske50:fix-swallowed-cancel
Open

Fix swallowed CancelledError in start_child_workflow and Nexus operations (Issue #1445)#1472
yegorske50 wants to merge 2 commits intotemporalio:mainfrom
yegorske50:fix-swallowed-cancel

Conversation

@yegorske50
Copy link
Copy Markdown

What was changed

Added the raise statement to the asyncio.CancelledError except blocks within _outbound_start_child_workflow and _outbound_start_nexus_operation in temporalio/worker/_workflow_instance.py.

Why?

Currently, if a cancellation request occurs while a parent workflow is yielding to start a child workflow or Nexus operation, the asyncio.CancelledError is caught to apply the cancel command, but it is not re-raised. Because this happens inside a while True loop, the error is swallowed, causing the parent workflow to completely ignore the cancellation and hang or proceed incorrectly. Re-raising enforces standard asyncio cancellation propagation and allows the workflow to shut down gracefully.

Checklist

  1. Closes [Bug] CancelledError is swallowed during workflow.start_child_workflow #1445

  2. How was this tested:

  • Created a local reproduction script using an empty task queue to force a hang on start_child_workflow, verifying the cancellation was previously ignored.
  • Verified that adding the raise statement allows the parent workflow to successfully catch the CancelledError and shut down.
  • Ran the local test suite (python -m pytest tests/worker/test_workflow.py), confirming no regressions in core workflow execution or deadlock detection.
  1. Any docs updates needed?
    None.

@yegorske50 yegorske50 requested a review from a team as a code owner April 22, 2026 21:03
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 22, 2026

CLA assistant check
All committers have signed the CLA.

@tconley1428
Copy link
Copy Markdown
Contributor

I don't believe this fix is correct, as asyncio.CancelledError is not guaranteed to come from cancellation of the worker. You should check that cancellation of the worker has actually been requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] CancelledError is swallowed during workflow.start_child_workflow

3 participants