Skip to content

Set finite default for ReadMaxBytes - #961

Closed
emcfarlane wants to merge 1 commit into
mainfrom
ed/setReadMaxDefault
Closed

Set finite default for ReadMaxBytes#961
emcfarlane wants to merge 1 commit into
mainfrom
ed/setReadMaxDefault

Conversation

@emcfarlane

@emcfarlane emcfarlane commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Set a default ReadMaxBytes of 4 MiB for both clients and handlers. Both previously defaulted to no limit.

The limit applies per message. Messages over the limit fail with CodeResourceExhausted.

This is a behavior change for anyone relying on unbounded reads. WithReadMaxBytes(0) restores the previous behavior, and existing WithReadMaxBytes(n) calls are unaffected. Handlers that want to bound the total size of a request stream rather than individual messages should still use http.MaxBytesHandler.

Signed-off-by: Edward McFarlane <emcfarlane@buf.build>
@emcfarlane

Copy link
Copy Markdown
Contributor Author

Closing, as I believe it to be too disruptive. This default will be set in v2 and the migrate tool will set the WithReadMaxBytes option to 0 to maintain the current behavior.

@emcfarlane emcfarlane closed this Aug 27, 2026
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