Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions crates/fbuild-daemon/src/handlers/operations/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,18 @@ pub async fn deploy(
{
Some(rx) => rx,
None => {
// open_port created the session above; a close/open race can
// drop its broadcaster before attach_reader runs. Release the
// handle the same way the normal path below does, or it stays
// open and the next client gets EBUSY (FastLED/fbuild#1426).
ctx.serial_manager.detach_reader(&monitor_port, &request_id);
if !ctx.serial_manager.has_clients(&monitor_port) {
ctx.serial_manager.close_port_after_grace_if_idle(
&monitor_port,
&request_id,
std::time::Duration::from_secs(2),
);
}
return (
StatusCode::OK,
Json(OperationResponse {
Expand Down Expand Up @@ -1228,6 +1240,19 @@ pub async fn deploy(
};

ctx.serial_manager.detach_reader(&monitor_port, &request_id);
// Detaching the reader alone leaves the session -- and its OS serial
// handle -- open forever, so the next client gets EBUSY on a board
// that is enumerated and perfectly healthy. The monitor and WebSocket
// cleanup paths both schedule the physical close here; this one did
// not, which is why the leak only showed up after a deploy.
// See FastLED/fbuild#1426.
if !ctx.serial_manager.has_clients(&monitor_port) {
ctx.serial_manager.close_port_after_grace_if_idle(
&monitor_port,
&request_id,
std::time::Duration::from_secs(2),
);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

return match monitor_result {
MonitorOutcome::Success(msg) => (
Expand Down
Loading