Skip to content

fix(grpc): handle NotImplementedError from add_done_callback in aio client#4672

Open
cschanhniem wants to merge 4 commits into
open-telemetry:mainfrom
cschanhniem:fix/pr-4429-grpc-aio-done-callback
Open

fix(grpc): handle NotImplementedError from add_done_callback in aio client#4672
cschanhniem wants to merge 4 commits into
open-telemetry:mainfrom
cschanhniem:fix/pr-4429-grpc-aio-done-callback

Conversation

@cschanhniem

Copy link
Copy Markdown

Fixes #4429

Problem

When a user interceptor awaits a grpc.aio call object, some interceptors wrap it in a type that does not implement add_done_callback. This causes a NotImplementedError that is not caught, leaving spans unfinished.

Solution

Catch NotImplementedError from call.add_done_callback() and invoke the callback immediately since code and details are already known at that point.

Changes

  • Wrap call.add_done_callback() in a try/except for NotImplementedError in _wrap_unary_response
  • When caught, call the callback immediately with the call object
  • Apply ruff formatting to changed files
  • Add test verifying the fallback behavior

Original PR: #4429 by @alliasgher

@cschanhniem cschanhniem requested a review from a team as a code owner June 8, 2026 05:58
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 8, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant