Commit 37b6092
authored
fix: align JSON-RPC client batch body limit with server default (#24953)
## Problem
The JSON-RPC client (`SafeJsonRpcClient`, used by PXE to talk to the
node via `createAztecNodeClient`) and the JSON-RPC server enforce two
batch limits: a max request count and a max body size. The request-count
limits already agree (both default to **100**), but the body-size limits
do not:
- Client: `DEFAULT_MAX_REQUESTY_BODY_SIZE = 10 * 1024 * 1024` (**10
MB**) — `foundation/src/json-rpc/client/safe_json_rpc_client.ts`
- Server: `maxBodySizeBytes: '1mb'` (**1 MB**, Koa `bodyParser`
`jsonLimit`) — `foundation/src/json-rpc/server/safe_json_rpc_server.ts`
Because the client only stops accreting a batch once the cumulative
encoded size reaches its own 10 MB cap, it can assemble a
sub-100-request batch between 1 MB and 10 MB that the node rejects at
the 1 MB body limit. That rejection is an HTTP 4xx, which the client's
fetch treats as a `NoRetryError`, so the **entire batch fails without
retry** and every request in it rejects. Large-payload paths (e.g.
`sendTx` with a Chonk proof, or a burst of witness queries coalesced
into one batch) are the realistic triggers.
## Change
Lower the client's default max batch body size to **1 MB** so it matches
the server's default `maxBodySizeBytes`. The client now flushes and
starts a new batch before crossing the limit the server enforces,
instead of building an over-limit batch that gets rejected.
- Request-count caps were already aligned (100 = 100); no change needed
there.
- `1mb` in the server config resolves to `1 * 1024 * 1024` bytes via the
`bytes` library, so the constants now match exactly.
## Notes
- The server's body limit remains configurable via `RPC_MAX_BODY_SIZE` /
`--rpcMaxBodySize`; this only changes the client-side *default*, which
is not env-configurable. Callers who talk to a node started with a
raised `RPC_MAX_BODY_SIZE` and who need larger client batches can still
pass an explicit `maxRequestBodySize` to `createSafeJsonRpcClient`.
- No test pins the old 10 MB default — the body-size unit test in
`safe_json_rpc_client.test.ts` passes an explicit `maxRequestBodySize`
override, so it is unaffected.
Context: raised from a research thread on PXE↔node RPC batching/limits.
---
*Created by
[claudebox](https://claudebox.work/v2/sessions/55ac241ae08220e9/jobs/2)
· group: `slackbot` · requested by Nicolás Venturo · [Slack
thread](https://aztecprotocol.slack.com/archives/C0BLBBGT3S4/p1784862842936309?thread_ts=1784862842.936309&cid=C0BLBBGT3S4)*1 parent 76a1caf commit 37b6092
1 file changed
Lines changed: 3 additions & 2 deletions
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
0 commit comments