Skip to content

[Bugfix] End the call when its status can't be sent - #145

Merged
theminjunchoi merged 2 commits into
mainfrom
fix/139-answer-hang
Nov 6, 2026
Merged

theminjunchoi merged 2 commits into
mainfrom
fix/139-answer-hang

Conversation

@theminjunchoi

@theminjunchoi theminjunchoi commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it:

Fixes #139

A handler that set details or trailing metadata the front can't take left the call open, so the client waited until its deadline. _answer() now ends the call with INTERNAL on any exception and logs it. If the front already ended the call, this does nothing.

server() also takes what grpc.server() takes here: bytes in set_details() and abort(), and None in set_trailing_metadata(). aio.server() ends a call with bytes details with INTERNAL, since grpc.aio refuses them.

How it was tested:

  • New tests check server() and aio.server() with bad details and trailing metadata on unary and stream calls. They fail without this change.
  • set_details() with bytes and set_trailing_metadata(None) match grpc.server() on server().
  • The full Python test suite passes (272 passed, 3 skipped), run on the 0.8.0 wheel since nothing in Rust changed. ruff passes.

Special notes for your reviewers:

Bad input still gets a different status from grpcio in some cases. For example, abort(code, 5) ends with INTERNAL here and keeps code on grpc.server(). The call ends either way, so I left those alone.

If applicable:

  • this PR changes user-facing behavior, and the README is updated
  • this PR contains tests

A handler that set details or trailing metadata the front can't take left the
call open until the client's deadline. server() also takes bytes details and
None trailing metadata, as grpc.server() does.

Signed-off-by: MinJun Choi <mj04300017@gmail.com>
Signed-off-by: MinJun Choi <mj04300017@gmail.com>
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

Perf: server cost per call

Head 9a00c5a against base 1274fc6, 10 rounds in random order on one runner (4 CPUs, grpcio 1.85.1). Run

Scenario Metric Base Head Change Head worse Verdict
low-level unary CPU µs/call 85.00 84.58 -0.5% 2/10 no change
low-level unary context switches/call 1.40 1.38 -1.4% 2/10 no change
server() unary CPU µs/call 142.50 142.50 -0.3% 3/10 no change
server() unary context switches/call 2.74 2.73 -0.4% 5/10 no change
aio.server() unary CPU µs/call 120.00 120.00 +0.0% 4/10 no change
aio.server() unary context switches/call 1.27 1.27 +0.3% 5/10 no change
server() stream CPU µs/call 300.00 297.92 +0.0% 4/10 no change
server() stream context switches/call 7.61 7.57 -0.4% 4/10 no change
aio.server() stream CPU µs/call 283.33 283.33 -0.7% 4/10 no change
aio.server() stream context switches/call 4.07 4.06 -0.5% 4/10 no change

@theminjunchoi
theminjunchoi merged commit 6d8b892 into main Nov 6, 2026
10 checks passed
@theminjunchoi
theminjunchoi deleted the fix/139-answer-hang branch November 6, 2026 02:11
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.

A call hangs when its details or trailing metadata can't be sent

1 participant