Skip to content

ci/rpc_client: runSingleTest streaming ack lands a premature response, then the 60s timeout fires before sendAsyncResponse arrives #3060

Closed

Description

@zackees

Symptom

runSingleTest is documented as a streaming, async-response RPC (Phase 3 in agents/docs/hardware-autoresearch.md):

REMOTE: {"success":true,"streamMode":true}
RESULT: {"type":"test_start", ...}
RESULT: {"type":"test_complete", ...}

The Python client (ci/rpc_client.py::RpcClient.send) treats it as a synchronous JSON-RPC call and times out at 60 s by default. With a moderate-sized strip (e.g. 100 LEDs × 4 patterns on Teensy 4) the device finishes the test in ~80–90 s but the client has already raised RpcTimeoutError and dropped the connection.

Reproducer

Live (today, 2026-06-14):

from ci.rpc_client import RpcClient
from ci.util.serial_interface import create_serial_interface
import asyncio

async def main():
    si = create_serial_interface("COM20", use_pyserial=True)
    c = RpcClient("COM20", timeout=60, serial_interface=si)
    await c.connect(boot_wait=2.0, drain_boot=True)
    r = await c.send("runSingleTest", args={
        "driver": "OBJECT_FLED",
        "laneSizes": [10],
        "pattern": "MSB_LSB_A",
        "iterations": 1,
    })
    print(r.data)

asyncio.run(main())

Output:

FAIL: RpcTimeoutError RpcTimeoutError('No response with ID 3 within 60.0s')

Bumping timeout= to 120 s lets the call complete and the device produces a valid RpcResponse — confirming the device is running the test, the client just isn't waiting long enough or isn't subscribing to the streaming RESULT: lane.

Where the seam is

RpcClient.send is built around request/response correlation by id. The async Phase 3 RPCs (runSingleTest, runParallelTest, all coroutine tests) instead emit:

  1. An immediate REMOTE: ack containing {"success": true, "streamMode": true}. The id here matches the request, so the current client sees a response and returns too early — but the test isn't actually finished.
  2. A sequence of RESULT: JSONL events for test_start, per-frame updates, and test_complete.
  3. (Only at the very end) a final REMOTE: reply via sendAsyncResponse(id=<original>) carrying the actual pass/fail payload.

The client today doesn't know about (1) being an ack vs (3) being the final answer — so it either:

  • Returns on (1) and the caller never sees the test result (silent green when device crashed mid-test), OR
  • Hangs on (1) when (1) is missing, and times out before (3) arrives.

In practice the synchronous path through await c.send("runSingleTest", ...) blocks on the final REMOTE: and times out because the test takes longer than the default 60 s for any non-trivial strip.

Asks

  1. Recognise the streaming envelope. When the first REMOTE: reply for a request carries streamMode: true, treat it as an ack and keep the request id armed. Only resolve the future when the matching sendAsyncResponse (or fail event) arrives.
  2. Per-method default timeout. Lift the per-call timeout for the Phase 3 RPCs (runSingleTest, runParallelTest, runNetClientTest, runNetLoopback, all testCoroutine*) from the global 60 s default to something matched to their actual upper bound (e.g. 600 s — these are HIL tests by design).
  3. Surface streaming events. Optionally expose RESULT: events to the caller via a callback (on_event=) so a host script can render progress instead of staring at a silent socket for two minutes.

Why this matters

Today the autoresearch host scripts paper over this by either:

  • Calling the lower-level bash autoresearch wrapper (which has its own monitor loop with a separate timeout), or
  • Bypassing the broker and reading the streaming JSONL directly with pyserial (ci/autoresearch/driver_sweep.py:214 — use_pyserial=True).

Both are workarounds. Fixing RpcClient to natively understand the streaming envelope removes the need for either, and lets agents call runSingleTest from any Python harness without rebuilding the timeout / streaming logic.

Related: FastLED/fbuild#592 §3.4 (singleton broker) is the long-term path that would also let multiple clients subscribe to the same RESULT: stream; this issue is the short-term fix that makes a single client work today.

Repro environment

Investigated as a follow-up to FastLED/fbuild#592 / FastLED/fbuild#593 / #3059 (the decoder-tolerance issue this RPC timeout was masking).

🤖 Investigated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions