Skip to content

[P1] Close upstream streams when viewers disconnect and health probes finish #171

Description

@cbulock

The stream route's response-close cleanup unregisters usage but never destroys or aborts the upstream request/body. A viewer disconnect can leave a paused live stream holding a tuner/provider connection. checkStream() in scripts/check-channel-health.js removes data listeners after its byte/time budget but likewise never destroys the GET body. Repeated scheduled probes can retain connections. The image proxy has similar missing cancellation/error cleanup.

Code: server/lineup.js#L451-L540. Reviewed 2026-09-06; these source files are unchanged between local 5ee8134 and GitHub main 0d923cf.

Evidence: Static lifecycle review of server/lineup.js, scripts/check-channel-health.js:checkStream, and libs/proxy-image.js. Existing playback tests mainly inspect response payloads rather than upstream close events.

Acceptance criteria:

  • Propagate downstream cancellation to both pending fetches and established upstream bodies.
  • Destroy health-probe bodies in finally after success, timeout, and error; ensure error bodies are also released.
  • Make cleanup idempotent and preserve accurate usage tracking.
  • Add streaming-server tests that assert upstream sockets close after client abort/probe completion and that repeated probes do not grow active connections.

Validation note: the local full test suite could not pass because the installed better-sqlite3 binary is incompatible with the available ARM64 Node runtime. Reproductions mentioned above use isolated dependencies and do not claim full application integration coverage.

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions