Skip to content

serial manager: add last-detach grace window before physical port close #632

Closed

Description

@zackees

Parent: #592

Problem

SharedSerialManager already enforces one daemon-owned SerialSession per port and fans serial output out through a broadcast channel, but both WebSocket and HTTP monitor cleanup physically close the OS serial handle as soon as the last reader/writer detaches.

That still preserves the close/reopen thrash described in #592: a client that logically closes and reconnects immediately can force a physical close/open cycle on the USB CDC port.

Scope

Add a daemon-side grace window for last-detach cleanup:

  • logical detach removes the subscriber immediately;
  • if the port has no readers/writer, schedule physical close after a short grace window (default 2s);
  • a new attach/open during the grace window cancels or invalidates the pending close and reuses the existing OS handle;
  • deploy preemption remains immediate and force-closes the port;
  • status/locks should still show an open session during the grace period so stale sessions are visible.

Acceptance

  • Unit tests cover pending close cancellation/reuse and delayed close execution.
  • WebSocket and HTTP monitor cleanup paths use the graceful last-detach helper instead of direct close_port.

Refs #592.

Activity

  1. added a commit that references this issue on Jun 18, 2026
    ead8b16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions