server: unary responses are sent as two DATA frames because `ConnectRpcBody` doesn't forward `is_end_stream`
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 53/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- grpc, rust
- Domain
- backend-api-design, networking
Research direction
Start by reading the http_body::Body implementations for ConnectRpcBody, GrpcUnaryBody, and StreamingResponseBody, then check how their inner body states affect is_end_stream() and size_hint(). Adapt the reproduction to this repository’s test fixtures, as the issue suggests. Done means unary responses use the correct end-of-stream behavior and tests cover the relevant body variants.
Written by the indexing model from the issue text.
Description
Summary
ConnectRpcBody (and GrpcUnaryBody, StreamingResponseBody) implement http_body::Body with
poll_frame only, so is_end_stream() and size_hint() fall back to the trait defaults (false
and unknown), even for the Full variant that wraps a Full<Bytes>.
hyper's HTTP/2 body pipe (hyper/src/proto/h2/mod.rs, PipeToSendStream) calls
is_end_stream() right after each data frame to decide whether to set END_STREAM on it. With the
default false, every unary response goes out as:
- a DATA frame with the payload and no END_STREAM, then
- on the next poll, which returns
None, an empty DATA frame with END_STREAM
(send_eos_frame).
The same check in hyper/src/proto/h2/server.rs has two more effects:
- An empty response body misses the headers-only fast path, which would put END_STREAM on the
HEADERS frame. - hyper never sets
content-lengthautomatically, because that path reads it from
size_hint().exact().
Why it matters
Besides one extra frame and one extra client wakeup per call, the first frame counts against
h2's small-DATA-frame budget (h2 0.4.16+). The budget charges every non-final DATA frame under
256 bytes 256 - len until the application reads it, against max(connection window / 2, 25,600). A final frame isn't charged. #319 describes the same budget from the server side.
With small unary replies (about 20–40 bytes), each reply costs about 230 bytes of the receiving
client's budget. A client using adaptive windows (Http2Connection::builder().adaptive_window(true)),
which start at 64 KiB, closes its own connection with
GOAWAY(ENHANCE_YOUR_CALM, "too_many_data_frames") once about 140 replies arrive before it
reads them. Every in-flight call on that connection then fails, with
h2 send failed: http2 error, operation was canceled: connection closed, or
failed to read response body: error reading a body from connection.
A server that batches work (for example, a group commit) and releases hundreds of replies onto
one connection at once trips this routinely. In our load tests (about 100-byte unary calls at
50K–100K/s over 4 connections per server), 1–3% of calls failed this way. They stopped
entirely once the clients used fixed 16 MiB connection windows. If the reply frames carried
END_STREAM, the budget would never be charged for unary calls, whatever the window.
Reproduction
The setup:
- Server: the built-in
Server(defaults), serving one unary method through
Router::routeandhandler_fn. The handler waits on atokio::sync::Barriersized to the
number of calls, then replies with a message of about 30 bytes. - Client: one
Http2Connection::builder().adaptive_window(true)connection (.shared(1024))
sending 200 concurrent unary calls, 200 being hyper's default stream limit. All the replies
leave the server together when the barrier opens. - Control: the same client with
.initial_connection_window_size(16 << 20) .initial_stream_window_size(4 << 20)instead of adaptive windows.
The results:
- Adaptive windows: 199 of 200 calls fail with
failed to read response body: error reading a body from connection, in 20 of 20 runs. - Fixed windows: all 200 calls succeed in every run.
The failed calls' errors don't name the reason; h2's log does. RUST_LOG=h2=debug on the
client shows each reply as two DATA frames, then the client's GOAWAY:
received frame=Headers { stream_id: StreamId(399), flags: (0x4: END_HEADERS) }
received frame=Data { stream_id: StreamId(399) }
received frame=Data { stream_id: StreamId(399), flags: (0x1: END_STREAM) }
...
send frame=GoAway { error_code: ENHANCE_YOUR_CALM, last_stream_id: StreamId(0), debug_data: b"too_many_data_frames" }
In the fixed-window run, the client received 200 DATA frames without END_STREAM and 200 with
it, two per reply. The server received each request as a single DATA frame with END_STREAM, so
the client's request bodies already report their end; only responses are affected.
The test is about 100 lines against our generated service types; I can adapt it to this repo's
test fixtures if that helps.
Potential Fix
Forward is_end_stream and size_hint in ConnectRpcBody to the inner body (Full<Bytes>
already reports both correctly), and implement them for GrpcUnaryBody and
StreamingResponseBody where the state allows. The Connect Full path then drops to a single
final frame. gRPC unary can't benefit: its payload frame must be followed by a trailers
HEADERS frame, which carries END_STREAM, so the DATA frame is always non-final and always
charged. That may be worth a note in the docs alongside the window-size guidance.
Versions: connectrpc 0.9.1 (also on main as of 2026-11-17), hyper 1.12.0, h2 0.4.20.
- Dominant language
- Rust
- Stars
- 544
- Forks
- 77
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from connectrpc/connect-rust
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
connectrpc/connect-rust#360 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
connectrpc/connect-rust#358 ·
-
Streaming request body errors are always reported as `internal`Possibly taken @AhmedElBanna80 claimed this 18 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 72/100
connectrpc/connect-rust#352 ·
-
Difficulty 3/5 Half a day Newbie friendliness 48/100
connectrpc/connect-rust#349 ·
-
Client fails 12 cases of connectconformance v1.0.7 (gRPC-Web bidi metadata, gRPC truncated server-stream message)Possibly taken @excavador claimed this 34 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 48/100
connectrpc/connect-rust#346 · 1 comment ·
All issues in connectrpc/connect-rust
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Choochmeque/tauri-plugin-webdriver#134 ·
Maintainers usually reply within 17 days
-
bug rust SDK & CLI & REST API
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
boxlite-ai/boxlite#3292 ·
Maintainers usually reply within 1 day
-
Android bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
anefzaoui/misterdownloadmanager#2516 ·
Maintainers usually reply within 1 day
-
editor ui
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
state:triage tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 89/100
agent8-cash/ethpayserver#731 ·
Maintainers usually reply within 1 day