Repository navigation
Conversation
DaleSeo
reviewed
Sep 6, 2026
DaleSeo
reviewed
Sep 6, 2026
DaleSeo
reviewed
Sep 6, 2026
GTanger
force-pushed
the
fix/streamable-http-response-limits
branch
from
September 8, 2026 00:08
a94edbc to
4500e81
Compare
Member
|
This has merge conflicts with |
Contributor
Author
|
Thanks @DaleSeo! Rebased onto the latest |
GTanger
force-pushed
the
fix/streamable-http-response-limits
branch
2 times, most recently
from
October 27, 2026 14:52
3e6deaa to
68f4af8
Compare
GTanger
force-pushed
the
fix/streamable-http-response-limits
branch
from
November 11, 2026 08:43
68f4af8 to
b9e0ad4
Compare
Contributor
Author
|
Rebased onto the latest
|
Expose configurable StreamableHttpResponseLimits (defaulting to 64 MiB
for complete JSON bodies on any HTTP status, 64 KiB for HTTP diagnostic
prefixes, and 16 MiB per SSE event) while preserving the v3.9.0
ResponseBodyTooLarge { max_size } error variant, HTTP 5xx status
metadata fallback, and reqwest charset/BOM decoding.
Truncate non-JSON diagnostic error bodies without waiting for EOF so
oversized legacy 4xx pages still reach server/discover fallback, align
Unix socket JSON-RPC error handling with reqwest, and forward limits
across all worker POST sites and AuthClient token refreshes.
GTanger
force-pushed
the
fix/streamable-http-response-limits
branch
from
November 13, 2026 18:59
b9e0ad4 to
51c9290
Compare
DaleSeo
reviewed
Nov 13, 2026
Restore StreamableHttpResponseLimits::default().max_json_response_size to 16 MiB (matching v3.9.0) so larger JSON payloads require explicit opt-in rather than expanding default client buffering. Route unchallenged 401/403 JSON responses through read_truncated_body under max_error_response_size in both reqwest and Unix socket backends instead of buffering up to max_json_response_size before truncating to a diagnostic prefix.
DaleSeo
approved these changes
Nov 13, 2026
This was referenced Nov 13, 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.
Summary
Refs #1030. Addresses the Streamable HTTP client JSON/error response scope described in #1180 and redirected to #1030 by the maintainer. The stdio work in #1049 remains separate; this PR should not close the combined tracker on its own.
The built-in clients already bound individual SSE events, but buffer JSON and HTTP error bodies before parsing them. This change adds configurable pre-decode bounds without replacing the transports or adding dependencies.
Changes
StreamableHttpResponseLimitsand transport config setters. Defaults: 16 MiB per complete JSON response, 64 KiB per HTTP diagnostic prefix, and the unchanged independent 16 MiB SSE-event limit.ResponseBodyTooLarge { max_size }if Content-Length exceeds its limit or a chunk would exceed it. Count bytes even when the length is missing or understated; do not drain oversized JSON to EOF.401/403responses (even whenapplication/json),read_truncated_bodyretains at most the diagnostic limit and stops immediately when that prefix is full, without polling for another chunk or EOF. Large legacy 4xx pages can still reach the existingserver/discover->initializefallback. The fallback eligibility rules are unchanged.application/jsonerror responses use the same complete-body JSON limit as successful responses. Parse the full bounded body before considering discovery fallback or truncating diagnostic text. Never parse a diagnostic prefix as a complete JSON-RPC message. Malformed/non-error JSON gets only a diagnostic prefix; oversized JSON still fails without fallback/retry.StreamableHttpPostResponse::Json, before synthetic discovery fallback. This also fixes the previous backend discrepancy for these errors.AuthClientpreserves them across token refresh.Compatibility and limits
Custom HTTP backends remain source-compatible, but must override
post_message_with_response_limitsto enforce JSON/diagnostic limits; the default cannot bound a body already decoded by custom code. The API docs explain this distinction and the JSON-versus-diagnostic behavior.JSON bodies above the 16 MiB default fail unless callers raise
max_json_response_size; callers can adjust each limit independently. A zero JSON limit accepts only empty bodies. A zero diagnostic limit omits diagnostic text rather than rejecting a non-JSON or401/403error response.Existing 202/204, authentication challenge, session-expired, within-limit malformed-success-JSON, and backend-specific success-body-I/O-error behavior is preserved. An error-body I/O failure before the diagnostic limit still uses the existing read-failure placeholder (subject to the diagnostic prefix limit). This does not subsume #1208's separate malformed-JSON proposal.
Limits count bytes yielded by the HTTP backend (decompressed bytes when decompression is enabled). They bound accumulated body length, not backend/decompressor allocations, vector capacity, UTF-8 conversion, or JSON parser allocations, and are not a total RSS bound.
Validation
cargo +nightly fmt --all -- --check), rustdoc (RUSTDOCFLAGS="-D warnings"), and strict Clippy (--all-targets --all-featuresand computed non-localfeature set) pass with zero warnings.test_streamable_http_response_limitswith and withoutreqwest/charset,test_unix_socket_response_limits,test_streamable_http_limit_lifecycle,test_streamable_http_default_error_limit,test_streamable_http_initialize_error,test_auth_error_classification,test_streamable_http_reconnect_classification) and fullrmcpunit/integration suites pass.401/403JSON responses truncated atmax_error_response_sizewithout buffering up tomax_json_response_sizeon both backends, old POST APIs, zero limits, EOF-free diagnostic prefixes, partial-JSON negatives, auth/session precedence, independent SSE limits, and lifecycle limit forwarding.Prepared with AI assistance; reviewed and tested locally before submission.