Conversation
The core now bounds what it admits: a document over JsonRpcLimits.MaxDocumentBytes (4 MiB by default) or a batch with more than MaxBatchCount entries (1024) is answered with -32600 and a data object naming the limit and the configured maximum, before anything is parsed or executed. The byte check runs at every public Process and ProcessAsync entry before any copy, flattening or transcoding (string overloads measure the UTF-8 byte count); the batch check runs after a full parse and before the first dispatch, so no prefix of an over-long batch executes. Config.SetLimits sets the process-wide value or a per-session override; zero disables a field and JsonRpcLimits.Unlimited restores the 1.x behaviour. Kestrel's MaxRequestBytes stays and is met first. README, SECURITY.md, CHANGELOG and docs/upgrading.md describe the limits and the staged host-responsibility paragraph.
This branch has not been deployed
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.
Third of the ten 2.0.0 pull requests sequenced in AUS-1001 (https://linear.app/austins-test/issue/AUS-1001). Ticket: https://linear.app/austins-test/issue/AUS-1004. Stacked on #164; retarget to master once that merges.
JsonRpcLimits(maxDocumentBytes = 4 MiB, maxBatchCount = 1024),Default,Unlimited;Config.SetLimits(limits)andConfig.SetLimits(sessionId, limits)(null inherits). Zero disables a field, negatives throw at construction.Process/ProcessAsyncentry before any copy, flattening, checked conversion or transcoding; string overloads measure the UTF-8 byte count and size the buffer by it. Batch check after a full parse and before the first dispatch, counting every top-level element; nothing in an over-long batch runs, notification-only batches included.{"jsonrpc":"2.0","error":{"code":-32600,"message":"Invalid Request","data":{"limit":"maxDocumentBytes","maximum":4194304}},"id":null}(ormaxBatchCount/1024) with the configured maximum, identical bytes for every serializer (LimitExceededInfowith its own writer), passed through the parse-error handler when one is set, like the empty-batch answer.MaxRequestBytesis unchanged and is met first (HTTP 413 / raw abort); a host that raises it gets the core answer.ProcessAsyncmemory entry keeps its base exception behaviour (faulted or cancelled task, no new exception region on the hot path).LimitsTests(16 cases across the three serializers) and two Kestrel cases; README (raw connections, error table, Configuration/Limits, Security), SECURITY.md, CHANGELOG (Added, Security) and docs/upgrading.md.Verification: Release build 0 warnings / 0 errors; 1216 tests pass on net8.0 and net10.0;
check_request_path_sync.py23 listed uses, none unlisted (no allowlist change);render.py --checkagrees.Reference machine (8 cores / 16 logical, about 20 percent foreign CPU load from other sessions throughout), base 4724600 vs this branch, interleaved pairs, medians with min..max:
--sync 3 16, 16 threads RPC/s--sync, allocation per numeric requestStringMe32 B both)--scale 3 16 4.0--async 3 16sync/None RPC/s--asyncTask/None--asyncValueTask/None--asyncyield rows and every B/RPCAsyncDispatchBenchmarks.SyncViaProcessAsync(default job, two pairs)ValueTaskInlineDispatchBenchmarks.Add/AddIntRaw run files are in the session scratchpad (
impl/aus-1004-bench*,impl/aus-1004-micro*).