Skip to content

add cancel_reason to RpcInvocationData - #809

Open
davidzhao wants to merge 1 commit into
mainfrom
dz/rpc-cancellation-reason
Open

add cancel_reason to RpcInvocationData#809
davidzhao wants to merge 1 commit into
mainfrom
dz/rpc-cancellation-reason

Conversation

@davidzhao

Copy link
Copy Markdown
Member

in order to allow downstream interceptors/tracing to determine why the call was not successful.

in order to allow downstream interceptors/tracing to determine why the
call was not successful.

@devin-ai-integration devin-ai-integration Bot 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.

Devin Review found 1 potential issue.

Devin Review

# only a cancel the chain accepted counts: cancel() is False when the chain has
# already finished, which can happen in the same loop iteration the timer fires
# while this task has not resumed yet; that result is the caller's, not a timeout
invocation.cancel_reason = RpcError.ErrorCode.RESPONSE_TIMEOUT

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.

🟡 Concurrent disconnect records wrong reason

When a room disconnect races the response deadline, cancel_reason reports RESPONSE_TIMEOUT while the caller receives RECIPIENT_DISCONNECTED. The deadline cancels the chain before the outer task handles the disconnect and replaces the reason.

Prompt for agents
Resolve cancellation precedence in LocalParticipant._run_incoming_chain so RpcInvocationData.cancel_reason observed during interceptor unwinding always matches the RpcError returned to the caller. A deadline callback can currently cancel the chain and expose RESPONSE_TIMEOUT before concurrent cancellation of the outer invocation enters the disconnect branch, which later returns RECIPIENT_DISCONNECTED. Add a deterministic race test covering both events in the same loop turn and coordinate the selected outcome before exposing the reason to the chain.
Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

2 participants