Skip to content

fix(rpc_client): restart wait after async ACK so Phase 3 RPCs aren't timed out by the pre-ACK budget (#3060) - #3062

Merged
zackees merged 1 commit into
masterfrom
fix/3060-rpc-streaming-async
Jun 15, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/3060-rpc-streaming-async

Conversation

@zackees

@zackees zackees commented Jun 15, 2026 •

Copy link
Copy Markdown
Member

Summary

RpcClient.send() already skipped {"acknowledged": true} ACKs from async (Phase 3) RPCs, but it kept reading inside the original caller-supplied timeout window. The runSingleTest path through 100 LEDs × 4 patterns on Teensy 4 takes 70-90 s of device-side work; the default 60 s budget fired before sendAsyncResponse landed, and surfaced as RpcTimeoutError('No response with ID N within 60s') even though the device was faithfully running the test.

After this PR, when the ACK arrives the client returns into a fresh _wait_for_response call with max(caller_timeout, ASYNC_POST_ACK_TIMEOUT=600s). Synchronous calls are unchanged (they never see an ACK); async calls get a budget large enough for any reasonable HIL test.

Why this didn't need a streaming-envelope rewrite

The investigation in #3060 hypothesised a missing {"streamMode": true} handler. Walking the firmware (src/fl/remote/rpc/rpc.cpp.hpp:115-117) and the existing client (ci/rpc_client.py:636-646), the actual envelope is {"acknowledged": true} and the client already skips it correctly. The bug was that the second wait (for the real result) still ran on the original ACK-budget clock, so any test taking longer than timeout post-ACK appeared identical to a hung device.

That made the fix narrower: keep the existing protocol handling, but restart the wait once the ACK proves the device is alive and running the test.

Live validation

Tested on the Teensy 4 attached to this workstation (COM20, OBJECT_FLED driver):

$ uv run python -c "..."
[RPC] ACK received for request 1, restarting wait for final response (post-ACK timeout=600.0s)...
FINAL: 4

Pre-fix, the identical call with timeout=10 raised RpcTimeoutError. Post-fix, the call returns the full test result (totalTests=4) without the caller having to manually bump the timeout.

Test plan

  • Live: runSingleTest via RpcClient(timeout=10) against attached Teensy 4 returns the expected result (was timing out pre-fix).
  • Smoke: RpcClient.ASYNC_POST_ACK_TIMEOUT is reachable as a class constant; module imports cleanly.
  • Synchronous RPCs (ping, status, drivers) — unchanged code path, no behaviour change.
  • CI

Closes #3060

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced asynchronous RPC call handling by improving acknowledgment processing. The system now properly extends response-waiting timeouts when receiving asynchronous acknowledgments, using a minimum 600-second buffer. This ensures final responses are reliably captured instead of timing out prematurely, particularly during long-running operations or extended network delays.

…timed out by the pre-ACK budget (#3060)

The async (Phase 3) RPCs — runSingleTest, runParallelTest, every
testCoroutine*, the net/ble runners — emit '{"acknowledged": true}'
as an immediate ACK and ship the actual result via sendAsyncResponse
once the test finishes. RpcClient.send already knew to skip the ACK and
keep waiting, but it kept reading inside the original timeout window
that started when the request was sent. For runSingleTest with 100 LEDs
on Teensy 4 the device-side work takes 70-90s; the default 60s timeout
fires before sendAsyncResponse lands, surfacing as

    RpcTimeoutError('No response with ID N within 60s')

even though the device is faithfully running the test.

Now, when the ACK arrives, the client returns from _wait_for_response
into a fresh _wait_for_response call with a post-ACK budget of
max(caller_timeout, ASYNC_POST_ACK_TIMEOUT=600s). Synchronous calls are
unchanged because they never receive an ACK; async calls get a budget
large enough for any reasonable HIL test. Callers that explicitly bump
the timeout above 600s still win.

Verified live on Teensy 4 (COM20): runSingleTest with default
timeout=10s now completes against OBJECT_FLED with the verbose log

    [RPC] ACK received for request 1, restarting wait for final response (post-ACK timeout=600.0s)...
    FINAL: 4

Pre-fix, the same call returned RpcTimeoutError at 60s with no result.

Closes #3060
@coderabbitai

coderabbitai Bot commented Jun 15, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 589d37bd-ae04-4ae6-90de-dff003a853d4

📥 Commits

Reviewing files that changed from the base of the PR and between 84ff2de and 2616023.

📒 Files selected for processing (1)
  • ci/rpc_client.py

📝 Walkthrough

Walkthrough

Adds RpcClient.ASYNC_POST_ACK_TIMEOUT = 600.0 as a class constant in ci/rpc_client.py. Modifies the ACK handling branch in _wait_for_response() to compute post_ack_timeout = max(timeout, ASYNC_POST_ACK_TIMEOUT) and recursively invoke _wait_for_response() with the same request ID, replacing the previous behavior of continuing within the original timeout window.

Changes

Async ACK post-response timeout restart

Layer / File(s) Summary
ASYNC_POST_ACK_TIMEOUT constant and _wait_for_response restart logic
ci/rpc_client.py
Adds ASYNC_POST_ACK_TIMEOUT = 600.0 class constant defining the post-ACK minimum wait floor. Rewires the ACK branch in _wait_for_response() to compute post_ack_timeout = max(timeout, ASYNC_POST_ACK_TIMEOUT) and recursively call _wait_for_response() with the same request ID and the new timeout, replacing the old continue that consumed the remaining original window. Updates verbose logging to reflect "restarting wait" semantics.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 The ACK came in, "I'm working!" it said,
But the clock kept ticking and timed out instead.
Now when the ack hops in, we restart the race,
Six hundred whole seconds — a much kinder grace!
No more dropped responses, no tears left to shed. 🕐

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/3060-rpc-streaming-async

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 15, 2026
@zackees
zackees merged commit 371286b into master Jun 15, 2026
7 of 8 checks passed
@zackees
zackees deleted the fix/3060-rpc-streaming-async branch June 15, 2026 05:08
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

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

1 participant