Repository navigation
fix(serial): bound pre-open family inference, log every WS open outcome (#2083 follow-up) - #2089
Merged
Merged
Conversation
…tcome Follow-up to #2084 for #2083. #2084 moved board-family inference out of the 3 s WebSocket open cap, but left it unbounded: a hung available_ports()/sysfs walk would now hold a serial attach pending forever, the #977 failure the cap exists to prevent. Bound it with OPEN_FAMILY_RESOLVE_TIMEOUT (5 s, CdcAcmBridge fallback) and log its time and outcome. Both WS open sites (initial attach and post-deploy recovery) now go through ws_serial_open_port_with_family, which resolves the family before the cap, logs the start and the outcome of the open with pre-open and open times, and appends the pre-open time to the failure message. The #2083 evidence had an "opening port" line with no outcome; a timed-out open was silent. Cancellation safety is unchanged: a timed-out open drops the spawn_blocking result (the serialport handle closes on drop) and the session is published with no await between the OS open and the insert, so nothing is half-open. Tests: resolve_family_bounded_falls_back_when_inference_stalls, resolve_family_bounded_keeps_family_inferred_in_time, ws_slow_family_resolution_does_not_consume_open_cap, ws_open_timeout_reports_pre_open_time.
Bench run on an LPC845-BRK under heavy load (load avg 90 on 16 cores): family inference alone took up to 6.3 s, past the Python client's 5 s attach handshake, so a 5 s bound helped nobody. Bound it at 3 s, and on expiry use the family the port last resolved to (recorded even when the inference finishes after the bound) instead of CdcAcmBridge, whose idle DTR/RTS is wrong for native-USB ESP32. Inference still runs on every attach, so a different board on a reused port name is detected whenever the host answers in time. Test: resolve_open_family_remembers_late_inference_for_next_timeout.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Only a timeout or panic falls back to the last resolved family. An inference that answers "unidentified" is authoritative: it gets CdcAcmBridge and clears the remembered family, so a board swapped onto a reused port name cannot inherit the previous board's DTR/RTS idle. Test: resolve_open_family_forgets_family_when_port_is_unidentified.
…open-timeout-2083
manager/tests.rs hit 1022 LOC and tripped the 1000-LOC gate.
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.
Fixes #2083
Follow-up to #2084. That PR fixed both halves of #2083: board-family inference now runs before the 3 s WebSocket open cap, and the client turns the daemon's
Errorframe intoConnectionFailed. Three things were still missing.family_for_port()(available_ports()plus sysfs) outside the cap but did not bound it. A hung enumeration would now leave a serial attach pending forever, which is the daemon: timeout WebSocket serial open_port pending attaches #977 failure the cap exists to prevent.SharedSerialManager::resolve_open_familyis now bounded byOPEN_FAMILY_RESOLVE_TIMEOUT(3 s).CdcAcmBridge.CdcAcmBridgeand clears the recorded family, so a board swapped onto a reused port name cannot inherit the previous board's DTR/RTS idle.CdcAcmBridge's idle DTR/RTS is wrong for a native-USB ESP32.opening portline with no outcome after it. Both WS open sites (initial attach and post-deploy recovery) now go throughws_serial_open_port_with_family. It logs the start and the outcome of every open withpre_open_msandopen_ms, and it appends(pre-open N ms)to the failure message the client now shows.Cancellation safety is unchanged and was checked. When the cap fires, the
spawn_blockingresult is dropped, and the serialport handle closes on drop. The session is published with no.awaitbetween the OS open and the map insert, so an open that times out cannot leave a session half-open.Why 3 s and not 5 s (bench data)
LPC845-BRK on
/dev/ttyACM1, dev daemon from this branch, PyPI 2.5.51AsyncSerialMonitorclient, 40 attach/detach cycles per run:Tests
fbuild-serial:resolve_family_bounded_falls_back_when_inference_stallsresolve_family_bounded_keeps_family_inferred_in_timeresolve_open_family_remembers_late_inference_for_next_timeoutresolve_open_family_forgets_family_when_port_is_unidentifiedresolve_open_family_is_total_and_boundedfbuild-daemon:ws_slow_family_resolution_does_not_consume_open_cap: 200 ms of inference against a 20 ms cap still attaches, and the open receives the resolved family.ws_open_timeout_reports_pre_open_timews_tests, including the pty production-path test and the preemption-recovery tests that drive the second call site.soldr cargo clippy -p fbuild-serial -p fbuild-daemon --all-targets --no-deps -- -D warningsis clean, andsoldr cargo fmtreports no changes.