Skip to content

Fix grpc-status sent as initial header instead of trailer.#1

Open
jmreid wants to merge 1 commit intosocketry:mainfrom
jmreid:fix-grpc-trailer-headers
Open

Fix grpc-status sent as initial header instead of trailer.#1
jmreid wants to merge 1 commit intosocketry:mainfrom
jmreid:fix-grpc-trailer-headers

Conversation

@jmreid
Copy link

@jmreid jmreid commented Mar 6, 2026

When a gRPC response includes a body, grpc-status must be sent as an HTTP/2 trailing HEADERS frame. However, invoke_service was adding grpc-status to response.headers before send_response called trailer!, causing it to be included in the initial headers instead of trailers.

Call trailer! at the start of invoke_service to mark the header position. Since trailer! uses ||= for @tail, the subsequent call in send_response is a no-op, and any headers added after our call (including grpc-status) are correctly positioned as trailers.

When a gRPC response includes a body, grpc-status must be sent as an
HTTP/2 trailing HEADERS frame. However, invoke_service was adding
grpc-status to response.headers before send_response called trailer!,
causing it to be included in the initial headers instead of trailers.

Call trailer! at the start of invoke_service to mark the header
position. Since trailer! uses ||= for @tail, the subsequent call in
send_response is a no-op, and any headers added after our call
(including grpc-status) are correctly positioned as trailers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant