Skip to content

fix(serial): native fbuild adapter reads until the caller's timeout - #4661

Merged
zackees merged 1 commit into
masterfrom
fix/native-serial-read-full-timeout
Oct 2, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/native-serial-read-full-timeout

Conversation

@zackees

@zackees zackees commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Problem

Since #4657, every bash autoresearch esp32c6 ... session fails before any driver test runs:

🔌 [RPC] Using NativeFbuildSerialAdapter backend
📤 [RPC] Sending: {"method":"ping",...,"id":1}
  [async-serial] E (3215) task_wdt: esp_task_wdt_deinit(650): Tasks/users still subscribed
❌ [RPC] Timeout: No response with ID 1 within 10.0s
...
📤 [RPC] Sending: {"method":"setPins",...,"id":3}
❌ [RPC] Timeout: No response with ID 3 within 26.9s
FAILURE class=timeout method=setPins

Root cause

fbuild's AsyncSerialMonitor.read_lines() returns only the first available batch. NativeFbuildSerialAdapter.read_lines() yielded that one batch and ended the generator, so when the batch was a device log line, the RPC reply in a later batch was never read. FbuildSerialAdapter already loops native reads until the deadline; its comment documents this exact contract. The Pico 2 smoke in #4657 passed because its replies happened to arrive in the first batch.

Fix

Loop native reads until the caller's timeout. The handling of preserved pending lines and early generator close is unchanged.

Evidence

  • A/B on ESP32-C6 (bash autoresearch esp32c6 --parlio --legacy --strip-sizes 1,2,3):
  • New test test_native_adapter_reads_past_first_batch_until_timeout delivers a reply from the second batch. The factory test's fake monitor now behaves like the real one (one batch, then it waits out the timeout); previously it asserted the single-batch behaviour.
  • uv run pytest ci/tests/test_serial_interface_reset.py: 11 passed. bash lint on both files passed.

Summary by CodeRabbit

  • Bug Fixes
    • Serial output now continues to be collected across multiple batches until the requested timeout expires, so later replies are less likely to be missed.
    • Lines not yet delivered are preserved when reading stops early and can be returned on a subsequent read.

fbuild's AsyncSerialMonitor.read_lines() returns only the first available
batch. NativeFbuildSerialAdapter (#4657) yielded that one batch and ended,
so an RPC reply arriving after a device log line was never read. On an
ESP32-C6 the task-watchdog boot message lands first, and every AutoResearch
session timed out on setPins. Loop native reads until the deadline, as
FbuildSerialAdapter already does.

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: FastLED/FastLED/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 896816ad-63d9-4b5b-aa49-92196af210af

📥 Commits

Reviewing files that changed from the base of the PR and between ec0a0f3 and e9c7b0f.

📒 Files selected for processing (2)
  • ci/tests/test_serial_interface_reset.py
  • ci/util/serial_interface.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

NativeFbuildSerialAdapter.read_lines now reads across multiple batches until the caller’s timeout expires. It yields pending lines between reads and retains undelivered lines if iteration ends early. Tests cover preserved lines and replies received in later batches.

Changes

Serial adapter batch reading

Layer / File(s) Summary
Read lines across batches
ci/util/serial_interface.py
read_lines continues fetching batches until its deadline. It yields pending lines between reads and retains undelivered lines when iteration ends early.
Test batch delivery and buffering
ci/tests/test_serial_interface_reset.py
Tests check that the monitor is read more than once, preserved lines are returned, and a later REMOTE: reply is delivered.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to e9c7b

The adapter can deliver a later reply within the read timeout, and no actionable merge-blocking risk remains after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to e9c7b

This is a narrow change to serial response delivery. Buffered lines remain available after early termination, and response matching remains in place. The external monitor’s cancellation and overlapping-read guarantees remain unverified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated exposure change is additional delivery from the configured serial monitor during an existing read. The inspected change does not demonstrate new tenant, credential, network, or tool authority.

Trust Boundaries and Controls

  • inferred — Later-batch delivery still passes through the existing RPC prefix, parsing, and request-ID checks. No bypass of these controls is demonstrated; a serial peer able to supply a matching response remains within the existing device-trust assumption.

Resilience and Maintainability Implications

  • inferred — Sequential buffering is supported, but exclusive reader ownership and cancellation coordination are not established by the inspected adapter and RPC methods. External monitor semantics are needed to determine whether overlapping reads or close/reconnect can lose or redistribute lines. The evidence does not establish that this PR introduced such failures.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: making the native Fbuild serial adapter read until the caller's timeout.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@zackees
zackees merged commit ba07078 into master Oct 2, 2026
119 checks passed
zackees added a commit that referenced this pull request Oct 2, 2026
…stic serial fake (#4665)

Review follow-ups from #4661 and #4662: the deferred synthesis path now has a
WS2812 case (only WS2814 was tested), the native serial test fake waits out
its timeout like fbuild's AsyncSerialMonitor, and the AutoResearch doc says
the RMT binding applies to any --legacy --rmt run.

Co-authored-by: Claude <[email protected]>
@zackees
zackees deleted the fix/native-serial-read-full-timeout branch November 5, 2026 05:52
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.

1 participant