fix(mesh): bound the control channel by maxBodyBytes, not the 1 MiB ws cap (CARD-24, #120)
The 1 MiB inbound cap from #107 applied to every WebSocket, the mesh control channel included. An RPC carries a whole request body, so a body inside maxBodyBytes could still overflow the cap once wrapped in an rpc-req frame, and the teapot then closed the whole channel with 1009: every request through that link failed 503 until it reconnected. The test asked for by the card (T1, a 1 MB JSON body at defaults) passes on Node, Deno and Bun, because a JSON body re-encodes to about its own size. Two other cases fail on all three before this change: - T1b: a 999 KB text body of quotes doubles under JSON escaping; - T4: maxBodyBytes raised to 4 MB, a 3.9 MB JSON body. The control channel's bound is now derived from the teapot's limits.maxBodyBytes via controlFrameLimit(): MAX_FRAME_CHARS (4,000,000) at the 1 MB default, scaled by the same ratio above it, never below maxWsMessageBytes. No new option. User @Ws routes keep maxWsMessageBytes: Node gets a second WebSocketServer for the control path, app.upgrade picks the bound from the path before subscribing, and Bun's single native maxPayloadLength is raised on a teapot only, leaving app.upgrade to close user routes 1009 itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
10 files changed
+525
-19
No files matched your search
@@ -83,6 +83,21 @@ npm treats versions as semver and semver forbids leading zeros.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **A mesh RPC whose body is within `maxBodyBytes` reaches the teapot again** (#120). The 1 MiB
|
||||
WebSocket cap from #107 also bounded the mesh control channel, so a request body that fit the
|
||||
HTTP limit could still exceed it once the teacup wrapped it in an RPC frame. A text body near
|
||||
1 MB was enough, because JSON escaping doubles every `"` and backslash, and any body limit raised
|
||||
above 1 MiB was capped at 1 MiB on the channel. Either way the teapot closed the whole channel
|
||||
with `1009`, and every request through that link failed with `503` until it reconnected.
|
||||
|
||||
The control channel is now bounded by the teapot's `limits.maxBodyBytes`: 4,000,000 bytes at the
|
||||
1 MB default, the figure its frame parser already used, and four times the body limit when that
|
||||
is raised. `limits.maxWsMessageBytes` still governs every user `@Ws` route, unchanged. On Bun,
|
||||
which takes one native payload limit for all sockets, a teapot raises that limit to the control
|
||||
channel's bound, so an oversized frame on a user route is refused by the framework instead: still
|
||||
`1009`, on every Bun version, where Bun before 1.4 refused natively by dropping the connection
|
||||
(`1006`).
|
||||
|
||||
- **`static` no longer serves files outside its root through a symlink** (#106). The traversal guard
|
||||
compared paths lexically, and the file read then followed symlinks, so `public/leak -> /etc/hosts`
|
||||
was served. Containment now compares real paths: the requested file, and a directory's
|
||||
|
||||
Reference in new issue
Block a user