Rust SDK: an outbound message over the 16 MiB frame limit is re-queued ahead of the registrations forever, taking the worker down
Summary
A message larger than 16 MiB sent by a Rust SDK worker takes the worker down permanently. The engine drops the connection on the oversized frame. The SDK re-queues the message and replays it first on every reconnect, ahead of the registration replay. From then on the worker reconnects every ~2.5 s and never re-registers anything, so every function it provides is gone until someone restarts it. The call that caused it only fails with invocation_stopped. No error ever names the size.
Observed (2026-09-29, local dev compose, engine 0.24.0, iii-sdk 0.23.0)
The harness worker called state::list on its harness_turn scope: 423 records, 17,236,367 bytes of JSON. That is more than 16,777,216.
harness.log:
17:50:06.216599Z WARN harness::inflight: orphaned-turn redrive pass failed error=harness/state: state::list harness_turn: remote error (invocation_stopped): Invocation stopped
17:52:06.218454Z WARN ... state::list harness_turn: remote error (function_not_found): Function state::list not found in namespace my-project.state.log (the state worker, which sent the 17 MB result):
17:50:06.216912Z WARN iii_sdk::iii: send failed; reconnecting error=websocket error: IO error: Connection reset by peer (os error 104)
17:50:08.218680Z INFO iii_sdk::iii: iii connected address=ws://127.0.0.1:49134
17:50:08.936687Z WARN iii_sdk::iii: failed to flush queue error=websocket error: IO error: Connection reset by peer (os error 104)
... the same connected / failed-to-flush pair every ~2.5 s, still looping 1.5 h laterIn the same millisecond the engine unregistered every state::* function. After that, every state-backed call in the namespace failed with Function state::get not found in namespace my-project.
Root cause
- Engine read limit.
ws_handleruses axum 0.8WebSocketUpgradedefaults, which are tungstenite'sWebSocketConfig:max_frame_size = 16 MiBandmax_message_size = 64 MiB. The tungstenite client never fragments, so each SDK message is one frame, and in practice the limit is 16 MiB. A larger frame makesws_rx.next()yieldErr(Capacity).Engine::handle_workerhandles it withSome(Err(_)) | None => break. The socket closes with unread data (RST) and nothing is logged. - SDK poison queue (
sdk/packages/rust/iii/src/iii.rs,run_connection). When a send fails, the SDK runsqueue.push(message)and reconnects. On reconnect it runsqueue.extend(self.collect_registrations()), which puts the registrations after the failed message. Thenflush_queuesends in order. The oversized message goes first and the engine drops the connection again.flush_queueputs it back at the head, and the registrations are never sent. The loop never ends.
Proposed fix (patch ready)
In send_ws, a serialized message larger than 16 MiB is never written to the socket. It fails on its own instead:
InvocationResult: an error result (payload_too_large, "message of N bytes exceeds the 16777216-byte websocket frame limit") is sent in its place, so the caller gets a real error.InvokeFunctionwith aninvocation_id: thattrigger()fails right away withRemote { code: "payload_too_large" }instead of waiting for its timeout.- Anything else: dropped with an
error!log.
The connection stays up, and nothing is re-queued. New wire test tests/oversized_frame.rs (MockEngine with the default tungstenite limits):
- It fails on main: the result never arrives, because the mock drops each reconnect.
- It passes with the patch.
- Clippy
-D warningsis clean, and every SDK test that does not need a live engine passes.
Also worth doing (engine)
- Log the read error in
handle_workerbefore thebreak(Some(Err(err)) => warn!(error = %err, ...)). This outage was silent on the engine side. - Either raise
max_frame_sizeto matchmax_message_size, or document 16 MiB as the protocol's per-message limit so every SDK (Node, Python, Go) can enforce it the same way.
Workers side: harness now reads turn records key by key (state::list_keys + state::get), so it no longer produces this frame. Any other state::list over a large scope, or any handler that returns more than 16 MiB, will still trigger it until this is fixed.
Source: iii-hq/iii