Skip to content

Pub/Sub: dead client Senders not cleaned up on abrupt disconnect #33

Description

@mack42

Source: Audit finding (LOW)

When a Pub/Sub subscriber disconnects abruptly (TCP RST, network partition, kill -9), the `mpsc::UnboundedSender` stored in `PubSubManager` is not removed until the next publish attempt fails. With many short-lived subscribers this leaks senders + their subscribed-channel entries.

Suggested approach:

  • On connection drop, `cleanup_pubsub` already removes the client — verify this path runs on *every* disconnect kind (panic in handler, decode error, etc.) by adding integration tests
  • Switch from `UnboundedSender` to a bounded `Sender` (e.g. capacity 1024) so a runaway publisher cannot OOM via a stuck subscriber
  • Periodic sweep: on each publish, drop sender entries whose channel is closed (`sender.is_closed()` or detect via send-error)

Files: `src/server/mod.rs` (PubSubManager), `src/server/connection.rs` (cleanup_pubsub).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtier-3Differentiator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions