Skip to content

A cancelled queue write can make a workflow report success #425

In review

Description

@WH-2099

On 66311bd, run a Start → Answer graph and have the ready queue raise asyncio.CancelledError when it receives the Answer task.
The dispatcher exits, but Engine.run() still yields GraphRunSucceededEvent.
If the queue cancels during startup or resume, the caller can miss the failed event altogether.

The caller should get a failed event and the scheduling error.
If the graph was already failing or aborted, an error while draining another node should preserve the original reason.

Activity

  1. self-assigned this
    on Nov 24, 2026
  2. dosubot commented on Nov 24, 2026

    @dosubot

    There are two exception boundaries involved here, so changing only the dispatcher would leave startup/resume uncovered:

    • The dispatcher catches only Exception. asyncio.CancelledError bypasses that handler, but its finally still calls complete() and closes the event stream. With no recorded error or abort, _emit_terminal_events() selects success. [1] [2]
    • Startup/resume scheduling happens before self._dispatcher.start(). Both the startup cleanup handler and the outer handler that yields GraphRunFailedEvent also catch only Exception, so cancellation bypasses both. Simply storing the cancellation would not suffice either: terminal-event emission re-raises the stored error through those same handlers. [2]

    The original-reason requirement needs separate attention: GraphExecution.fail() unconditionally replaces error, while abort() stores its reason in that same field. A secondary drain error therefore needs to leave an existing failure or abort reason intact. [3]

    Related regression context: #404 reports the same dispatcher-finalization path producing false success after GeneratorExit. That makes consumer closure worth keeping distinct from queue-write cancellation when adjusting these boundaries. [4]

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

    Leave Feedback Ask Dosu about graphon

  3. QuantumGhost commented on Nov 24, 2026

    @QuantumGhost
    Member

    I'm wondering what's the rationale behind handling asyncio.CancelledError in Graphon. AFAIK, the base assumption of Graphon is that it only support synchronous function call, and utilize (either native or gevent-patched) thread for concurrency / paralleism. In such runtime, asyncio.CancelledError should not be raised.

    Besides, BaseException in Python is special since many CPython runtime components depend on correct handling of those exceptions. This is exactly the reason why BaseException is not a subclass of Exception: to avoid unintentional capture of those exceptions.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions