Skip to content

bug: FbuildSerialAdapter 50ms read timeout drops RPC responses #49

@zackees

Description

@zackees

Summary

FbuildSerialAdapter has timing characteristics that cause JSON-RPC ping responses to be dropped during FastLED's autoresearch GPIO pre-test on ESP32-S3. The root cause is a combination of short timeouts and early loop exit behavior.

Cross-reference

Downstream fix applied in FastLED/FastLED#2261 — autoresearch now always uses PySerialAdapter for RPC communication as a workaround.

Root Cause

Three compounding issues in FbuildSerialAdapter:

  1. 50ms read timeout per iteration — too short for an ESP32-S3 RPC round-trip (device must parse JSON-RPC request, execute handler, serialize response)
  2. Early exit on buffer drain timeout — stops reading before the response arrives, discarding partially-received data
  3. Async/sync boundary crossing via ThreadPoolExecutor adds non-deterministic latency to the read path

Observed Behavior

  • Schema validation phase uses PySerialAdapter with reset_input_buffer()succeeds
  • GPIO pre-test uses FbuildSerialAdapter (when serial_interface=None falls through to default) → consistently times out waiting for RPC ping response

Suggested Fix

Either:

  • Increase the per-read timeout to ≥500ms for serial reads
  • Don't exit early on buffer drain — continue reading until the caller's overall timeout expires
  • Or expose a configurable read timeout that callers can set for RPC use cases

Workaround

FastLED/FastLED#2261 forces PySerialAdapter for all RPC communication, bypassing FbuildSerialAdapter entirely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions