fix(protocol): size RESP payload cap from --storage-max-value and reply gracefully on oversize - #31
Merged
Conversation
…ly on oversize The RESP2 handler capped a single bulk string at a hard-coded 64 MiB and, on exceeding it, dropped the connection with no reply. A client storing a value larger than 64 MiB (e.g. a build cache pushing a large object) therefore saw an abrupt TCP reset, and raising --storage-max-value above 64 MiB had no effect because the wire cap fired first. - Replace the hard-coded MaxPayloadBytes constant with SessionContext::maxPayloadBytes (default: the 64 MiB floor). The daemon raises it to max(floor, storageMaxValueBytes), so --storage-max-value now drives both the wire and the storage limit from one knob: any value the cache will store can also be received off the wire. - On a parse error other than Truncated (a genuine protocol violation such as PayloadTooLarge / MalformedFrame / LineTooLong) reply "-ERR Protocol error: ..." before closing, mirroring Redis, instead of a bare connection reset. A Truncated frame (peer hung up mid-message) still just drops. - Add RESP regression tests for the per-session cap and the graceful error reply. Signed-off-by: Christian Parpart <c.parpart@lastrada.net> Claude-Session: https://claude.ai/code/session_01ERPincVQJuZoWhE77VSWTh
christianparpart
force-pushed
the
fix/resp-large-payload-cap
branch
from
July 9, 2026 07:10
46c714f to
2d055e9
Compare
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.
Problem
The RESP2 handler capped a single bulk string at a hard-coded 64 MiB and, on exceeding it, closed the connection with no reply — the client saw a bare TCP reset (
ECONNRESET/ WSA10054). Two consequences:sccachepushing a large compiled object into the cache) had its connection abruptly reset mid-command, failing the operation.--storage-max-valueabove 64 MiB had no effect: the wire-layer cap fired before the (configurable, graceful) storage-layer cap could.Fix
MaxPayloadBytesconstant withSessionContext::maxPayloadBytes(default: the 64 MiB floor). The daemon raises it tomax(floor, storageMaxValueBytes), so--storage-max-valuedrives both the wire and the storage limit from one knob — any value the cache will store can also be received off the wire.Truncated(a genuine protocol violation:PayloadTooLarge/MalformedFrame/LineTooLong), the handler now replies-ERR Protocol error: …before closing, mirroring Redis. ATruncatedframe (peer hung up mid-message) still just drops — there is nothing to reply to.Tests
+OK); a value exceeding it now receives-ERR Protocol error: …rather than an abrupt close.[protocol]suite green: 2070 assertions, 326 cases.https://claude.ai/code/session_01ERPincVQJuZoWhE77VSWTh