add cancel_reason to RpcInvocationData - #809
Open
davidzhao wants to merge 1 commit into
Open
Conversation
in order to allow downstream interceptors/tracing to determine why the call was not successful.
davidzhao
requested review from
cloudwebrtc,
lukasIO and
xianshijing-lk
as code owners
September 9, 2026 05:39
| # 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 |
Contributor
There was a problem hiding this comment.
🟡 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.
Was this helpful? React with 👍 or 👎 to provide feedback.
cloudwebrtc
approved these changes
Sep 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
in order to allow downstream interceptors/tracing to determine why the call was not successful.