Skip to content

[WORKFLOW SDK BUG] In-flight wait grace window fails to refresh on UNAVAILABLE or FAILED_PRECONDITION after healthy wait #1378

Open

Description

@NaniToka

Following up on the review discussion with @CasperGN in #1370:

Expected Behavior

In TaskHubGrpcClient._call_with_transient_retry (and its async counterpart in AsyncTaskHubGrpcClient), when an unbounded orchestration wait (wait_for_workflow_completion with timeout=None or 0) has been in-flight and healthy for a substantial duration, any transient server error in _TRANSIENT_RPC_CODES (including StatusCode.UNAVAILABLE and StatusCode.FAILED_PRECONDITION caused by sidecar restart) should refresh the 30-second transient grace window (_MAX_TRANSIENT_RETRY_SECONDS = 30.0), giving the restarting Dapr sidecar time to recover.

Actual Behavior

The healthy-wait grace-window refresh currently checks only for StatusCode.CANCELLED:

if unbounded:
    if code == grpc.StatusCode.CANCELLED and call_duration >= 1.0:
        if consecutive_resets < self._MAX_CONSECUTIVE_TRANSIENT_RESETS:
            consecutive_resets += 1
            transient_deadline = None
            backoff = 0.5

When a Dapr sidecar (daprd) restarts or is terminated during an in-flight wait, gRPC frequently surfaces the disconnection as StatusCode.UNAVAILABLE ("transport closing" / "connection refused") or StatusCode.FAILED_PRECONDITION.

Because code == StatusCode.CANCELLED evaluates to False:

  1. transient_deadline is not refreshed.
  2. If the previous in-flight wait lasted longer than 30 seconds (call_duration >= 30.0s), the check time.monotonic() >= transient_deadline evaluates to True on the very first attempt.
  3. The client immediately raises grpc.RpcError(StatusCode.UNAVAILABLE) instead of backing off and allowing the sidecar its 30-second restart window.

Steps to Reproduce the Problem

  1. Start an unbounded workflow wait: client.wait_for_workflow_completion(instance_id, timeout=None) on a workflow that takes longer than 30 seconds.
  2. Terminate or restart daprd after ~35 seconds while the wait is held.
  3. The gRPC transport returns StatusCode.UNAVAILABLE.
  4. Observe that the client immediately crashes with grpc.RpcError instead of retrying across the 30-second transient grace window.

Code Pointers & Proposed Fix

  • dapr/ext/workflow/_durabletask/client.py: Lines 520–545
  • dapr/ext/workflow/_durabletask/aio/client.py: Lines 420–445
  1. Broaden the healthy-wait reset check from code == grpc.StatusCode.CANCELLED to code in _TRANSIENT_RPC_CODES.
  2. Extract the hardcoded 1.0s healthy-wait threshold into a named constant (e.g., _HEALTHY_WAIT_THRESHOLD_SECONDS = 1.0) shared across sync and async clients.
  3. Add unit tests covering sidecar restart producing UNAVAILABLE after an in-flight wait > 30s.

cc @CasperGN

Release Note

RELEASE NOTE: FIX Refresh transient retry grace window on UNAVAILABLE and FAILED_PRECONDITION during in-flight workflow waits.

Activity

  1. itzzdev09 commented on Nov 25, 2026

    @itzzdev09
    Contributor

    I'd like to take this one, covering both TaskHubGrpcClient and AsyncTaskHubGrpcClient, unless someone is already on it.

  2. itzzdev09 commented on Nov 25, 2026

    @itzzdev09
    Contributor

    Heads up: the healthy-wait CANCELLED refresh this issue refers to (call_duration, consecutive_resets) is in #1370, which isn't merged, so there's nothing on main to change yet. I'll pick this up once #1370 lands, if it's still open then.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    dapr-ext-workflowkind/enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions