-
Notifications
You must be signed in to change notification settings - Fork 21.8k
Description
System information
Geth version: Geth 1.17.0-unstable (go1.24.0/linux-amd64)
CL client & version: N/A
OS & Version: Ubuntu 24.04.3 LTS (Linux x86_64, kernel 6.14.8-2-pve)
Commit hash : 15a9e92bbd310eca6da2e0f49c34b2e503dfbc00
Expected behaviour
When Server.SetBatchLimits(itemLimit, maxResponseSize) (or WithBatchResponseSizeLimit) is configured, the server should stop processing additional items in a batch once the cumulative response size exceeds maxResponseSize.
This limit should apply uniformly to both:
- Successful responses (
result) - Error responses (
error, includingerror.dataviarpc.DataError)
Once the limit is exceeded, subsequent batch items should return -32003 (response too large).
Actual behaviour
In rpc/handler.go, (*handler).handleBatch only accounts for len(resp.Result) when accumulating responseBytes.
For error responses:
resp.Resultisnil- Large error payloads (especially large
error.data) are not counted towardBatchResponseMaxSize
As a result, batch responses can significantly exceed maxResponseSize, and -32003 (response too large) is not reliably returned for later batch items.
Steps to reproduce the behaviour
-
Configure an RPC server with a small batch response size limit, e.g.:
srv.SetBatchLimits(1000, 200)
-
Register an RPC method that always returns an error implementing
rpc.DataErrorwith a largeErrorData()payload (e.g. a long string). -
Send a JSON-RPC batch containing multiple calls to that method.
-
Observe that:
- The total batch response exceeds
maxResponseSize - All (or too many) batch items are processed
- Subsequent items do not consistently return
-32003
- The total batch response exceeds