Mesh: more than ~16 in-flight requests on one link drops the control channel #148

Closed
opened 2026-10-23 05:11:35 +00:00 by chrnx · 2 comments
Owner

Found while implementing CARD-19 (core PR #146); reproduces on develop with only #137 applied.

With more than about 16 requests in flight over one teacup→teapot mesh link, the link drops and every pending request gets 503.

Likely cause: #107 (core #117) bounds every inbound WebSocket connection with limits.maxWsQueue (default 16 undelivered messages, close 1013), and the mesh control channel goes through the same boundInbound (src/http/ws-core.ts). A burst of RPC envelopes is a normal workload for the control channel, not a slow consumer. This is the queue-side sibling of #120 (message size vs maxWsMessageBytes, CARD-24).

To decide: exempt the control channel from maxWsQueue, or derive its cap from something mesh-specific (e.g. a concurrency bound), consistent with whatever CARD-24 does for message size.

Found while implementing CARD-19 (core PR #146); reproduces on develop with only #137 applied. With more than about 16 requests in flight over one teacup→teapot mesh link, the link drops and every pending request gets `503`. Likely cause: #107 (core #117) bounds every inbound WebSocket connection with `limits.maxWsQueue` (default **16** undelivered messages, close `1013`), and the mesh control channel goes through the same `boundInbound` (`src/http/ws-core.ts`). A burst of RPC envelopes is a normal workload for the control channel, not a slow consumer. This is the queue-side sibling of #120 (message size vs `maxWsMessageBytes`, CARD-24). To decide: exempt the control channel from `maxWsQueue`, or derive its cap from something mesh-specific (e.g. a concurrency bound), consistent with whatever CARD-24 does for message size.
Author
Owner

Merged into develop in #142 (CARD-24, FPRD-001c, 2026-10-23). Left open until the 1c acceptance gate (CARD-22), per the 1a/1b convention.

Merged into develop in #142 (CARD-24, FPRD-001c, 2026-10-23). Left open until the 1c acceptance gate (CARD-22), per the 1a/1b convention.
Author
Owner

Fixed in 26.11.0-rc.1 (8f73779, cad8122). From the changelog:

  • More than 16 mesh RPCs in flight on one link no longer drop the control channel (#148). The 16-frame inbound queue from #107 (limits.maxWsQueue) also applied to the control channel. On Node, ws delivers every frame of one socket read at once, so a teacup sending a burst of RPCs got the channel closed with 1013, and every pending request failed with 503. The control channel now has its own queue bound of 4,096 frames, or maxWsQueue if that is larger, which is more than one socket read can carry. User @Ws routes keep closing 1013 at maxWsQueue. Deno and Bun deliver frames one at a time and did not hit this, but they now share the same bound. Both larger bounds, this one and the frame size from #120, apply only once the peer's hello is accepted. Until then the control channel takes frames of at most 64 KiB and queues at most 16, and closes with 1009 or 1013 past that. An unauthenticated peer can therefore make a teapot hold about 1 MiB per connection, including while app.upgrade waits for a slow boot, instead of thousands of multi-megabyte frames.
Fixed in **26.11.0-rc.1** (`8f73779`, `cad8122`). From the changelog: - **More than 16 mesh RPCs in flight on one link no longer drop the control channel** (#148). The 16-frame inbound queue from #107 (`limits.maxWsQueue`) also applied to the control channel. On Node, `ws` delivers every frame of one socket read at once, so a teacup sending a burst of RPCs got the channel closed with `1013`, and every pending request failed with `503`. The control channel now has its own queue bound of 4,096 frames, or `maxWsQueue` if that is larger, which is more than one socket read can carry. User `@Ws` routes keep closing `1013` at `maxWsQueue`. Deno and Bun deliver frames one at a time and did not hit this, but they now share the same bound. Both larger bounds, this one and the frame size from #120, **apply only once the peer's `hello` is accepted**. Until then the control channel takes frames of at most 64 KiB and queues at most 16, and closes with `1009` or `1013` past that. An unauthenticated peer can therefore make a teapot hold about 1 MiB per connection, including while `app.upgrade` waits for a slow boot, instead of thousands of multi-megabyte frames.
chrnx closed this issue 2026-11-18 01:04:15 +00:00
Sign in to join this conversation.