Repository navigation
fix(serial): resolve board family before the WS open cap; surface the daemon's error text - #2084
Merged
Merged
Conversation
WebSocket serial attach wrapped open_port in a 3 s deadline, but open_port inferred the board family first: available_ports() plus sysfs health can take seconds on a loaded host, so healthy attaches failed as "exceeded 3s" before the tty was opened (the OS open is ~2 ms). The client then discarded the daemon's error frame and reported only "session closed". - SharedSerialManager::resolve_open_family runs family_for_port_or_default on spawn_blocking and is total (CdcAcmBridge fallback, the same (true, true) idle DTR/RTS state open_port applies for None). - Both WS open sites resolve the family before starting the timed open and pass it as the explicit family argument. - fbuild-python maps ServerMessage::Error on the attach reply to ConnectionFailed so the daemon's diagnosis reaches the caller. Fixes #2083
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
The first cut pushed serial_session.rs to 1008 LOC, which the LOC gate rejects. Fold the error-frame case into the shared attach-rejection arm (an or-pattern; both frames carry a reason string), and use let-else for the non-text frame. Net file size is 999 LOC.
This was referenced Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Issue #2083, from FastLED AutoResearch on an LPC845-BRK: 5 of 12 post-deploy
AsyncSerialMonitorattaches failed with onlyConnectionError: session closed,while the daemon log showed the open starting 3.3–3.6 s after the attach was
pending — i.e.
WS_SERIAL_OPEN_PORT_TIMEOUT(3 s) had already fired duringboard-family inference, before the tty was ever opened (the OS open itself is
~2 ms).
Two defects, both fixed here:
family_for_port()walksavailable_ports()plus sysfs health and runs inside theopen_portfuture,so the WS handler's 3 s deadline covered enumeration, not just the open.
SerialSession::connectonlyunderstood
attached; the daemon'serrorframe fell into the wildcard andbecame a bare
session closed.What
fbuild-serial: newSharedSerialManager::resolve_open_family(&self, port)— runs
family_for_port_or_defaultonspawn_blockingand is total (a portthat cannot be identified yields
BoardFamily::CdcAcmBridge, the same(true, true)idle DTR/RTS stateopen_portalready applies forNone).fbuild-daemon: both WS open sites (initial attach and the post-deployrecovery reopen) resolve the family before starting
await_ws_serial_open_portand pass it as the explicitfamilyargument, sothe timed region now covers only the OS open and its retries.
fbuild-python:ServerMessage::Error { message }on the attach reply nowreturns
SessionError::ConnectionFailed("daemon rejected serial attach: …"),so callers see
open_port(/dev/ttyACM1) exceeded 3s; …instead ofsession closed.Ask 3 of the issue (make the cap configurable / longer) is deliberately not
implemented: after moving inference out of the timed region the cap only covers
an open that takes ~2 ms in the reported runs, so widening it would mask real
driver wedges rather than help.
Tests
soldr cargo test -p fbuild-serial --lib→ 207 passed, 0 failed, 1 ignored(includes new
resolve_open_family_is_total_and_bounded).soldr cargo test -p fbuild-python --lib→ 69 passed, 0 failed(includes new
attach_error_frame_surfaces_daemon_reason, which drives thereal
SerialSession::connectagainst a fake daemon that answers the attachwith
{"type":"error","message":"open_port(/dev/ttyACM1) exceeded 3s; …"}and asserts the text reaches the caller).
soldr cargo test -p fbuild-daemon --lib→ 330 passed, 0 failed, 3 ignored(existing real-pty WS attach test now exercises the pre-resolved-family path).
soldr cargo fmt -p fbuild-serial -p fbuild-daemon -p fbuild-python -- --check→ clean.Fixes #2083
Note: the first push pushed
serial_session.rsto 1008 LOC and tripped the1000-LOC gate; the final commit folds the error-frame case into the shared
attach-rejection arm (both frames carry a reason string) and uses
let-elsefor non-text frames, landing the file at 999 LOC.