Skip to content

fix(workflow): gracefully handle 'actor is closed' gRPC error in workflow monitor - #714

Open
praneshnikhar wants to merge 3 commits into
dapr:mainfrom
praneshnikhar:fix-520-actor-closed-error
Open

fix(workflow): gracefully handle 'actor is closed' gRPC error in workflow monitor#714
praneshnikhar wants to merge 3 commits into
dapr:mainfrom
praneshnikhar:fix-520-actor-closed-error

Conversation

@praneshnikhar

Copy link
Copy Markdown

Description

The _await_and_log_state background task can encounter a gRPC
_InactiveRpcError with details "actor is closed, cannot handle
deactivated"
when the workflow actor is deactivated (scale-to-zero)
while the fire-and-forget monitor is still polling for completion.

This is a transient, non-fatal condition — the workflow itself
continues executing successfully. Previously it was logged as a
full exception traceback at ERROR level, which alarmed operators
unnecessarily.

Changes

  • Catch _InactiveRpcError with "actor is closed" in
    _await_and_log_state and log at WARNING with a clear
    explanation instead of ERROR.
  • Other exceptions continue to be logged at ERROR as before.

Before

ERROR:dapr_agents.workflow.runners.base:[agent-runner] 231e...: error while monitoring workflow outcome
Traceback (most recent call last):
  ...
grpc._channel._InactiveRpcError: ... "actor is closed, cannot handle deactivated"

After

WARNING:dapr_agents.workflow.runners.base:[agent-runner] 231e...: workflow monitor interrupted because the actor was deactivated (expected during scale-to-zero). Outcome will be checked on next poll.

Fixes #520

@praneshnikhar
praneshnikhar requested review from a team as code owners July 29, 2026 06:26
…flow monitor

The _await_and_log_state background task can encounter an
_InactiveRpcError with 'actor is closed' when the workflow actor
is deactivated during scale-to-zero while monitoring is in progress.
This is a transient, non-fatal condition.

Previously this was logged as a full exception traceback at ERROR
level. Now it is caught specifically and logged as a WARNING with
a clear explanation, so operators are not alarmed by expected
behavior.

Closes: dapr#520
Signed-off-by: praneshnikhar <praneshnikhar@gmail.com>
@praneshnikhar
praneshnikhar force-pushed the fix-520-actor-closed-error branch from da90149 to e43ce11 Compare August 5, 2026 12:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces operational noise in WorkflowRunner by treating the transient gRPC “actor is closed” condition (common during scale-to-zero/deactivation) as a non-fatal monitoring interruption rather than an error-level exception.

Changes:

  • Adds a special-case handler in _await_and_log_state to downgrade the “actor is closed” monitoring failure to WARNING.
  • Preserves ERROR/traceback logging for all other monitoring exceptions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +600 to +616
except Exception as exc:
import grpc

if (
isinstance(exc, grpc._channel._InactiveRpcError)
and "actor is closed" in exc.details()
):
logger.warning(
"[%s] %s: workflow monitor interrupted because the actor was deactivated "
"(expected during scale-to-zero). Outcome will be checked on next poll.",
self._name,
instance_id,
)
else:
logger.exception(
f"[{self._name}] {instance_id}: error while monitoring workflow outcome",
)
Comment on lines +603 to +612
if (
isinstance(exc, grpc._channel._InactiveRpcError)
and "actor is closed" in exc.details()
):
logger.warning(
"[%s] %s: workflow monitor interrupted because the actor was deactivated "
"(expected during scale-to-zero). Outcome will be checked on next poll.",
self._name,
instance_id,
)
@sicoyle

sicoyle commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

@praneshnikhar could you pls see the PR feedback 🙏

@praneshnikhar

Copy link
Copy Markdown
Author

@praneshnikhar could you pls see the PR feedback 🙏

hey gimme sometime working on it!

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.

Workflow monitor throws "actor is closed" error during active DurableAgent execution

3 participants