Skip to content

[bug] Orphaned playback sessions persist indefinitely when web client unmounts during auth expiry #3540

Open

Description

@M3th0s

What happened

When a web client's auth session expires during media playback, subsequent player unmount teardown (DELETE /api/v2/playback/{session_id}) fails with HTTP 422 validation_failed (auth_class=anonymous). Because the teardown is rejected, playback_session_lifecycle never transitions to state = 'stopped'.

When the user re-authenticates and resumes playback, a second playback session is registered (POST /api/v2/playback/start). This leaves the original session orphaned in PostgreSQL playback_session_lifecycle (state = 'paused', has_playback_control: false) and permanently listed in /api/v2/admin/sessions and the Admin Activity dashboard until manually terminated.

Steps to reproduce

  1. Start playback of any video title in the Silo Web UI (Silo Web 0.0.1).
  2. Pause playback mid-stream.
  3. Allow the web session/token to expire (or simulate token expiration).
  4. Refresh or navigate away from the page so the web client triggers player unmount cleanup (DELETE /api/v2/playback/{session_id}).
  5. Inspect server logs: observe status=422 error_code=validation_failed auth_class=anonymous on DELETE /api/v2/playback/{session_id}.
  6. Re-authenticate / select profile and resume playback (POST /api/v2/playback/start).
  7. Open Admin > Activity / Sessions (or GET /api/v2/admin/sessions).
  8. Notice both sessions appear simultaneously: the newly resumed stream and the older paused stream (has_playback_control: false) showing active session duration ticking up without an active player.

Expected behavior

  1. Player teardown cleanup (DELETE /api/v2/playback/{session_id}) should be accepted when presenting the playback session identifier, or the web client should refresh credentials prior to firing teardown, so client-side unmount does not fail with HTTP 422.
  2. The server backend should have an automated reaper/dead-man's switch: when a session's playback control channel is lost (has_playback_control: false) and no progress updates or heartbeats are received within an idle threshold (e.g. 10–15 minutes), the server should transition playback_session_lifecycle from state = 'paused' to state = 'stopped' (end_reason = 'idle_timeout' or 'client_abandoned').

Silo version / commit

build-1919 · baf9d426 (ghcr.io/silo-server/silo-server:latest, revision baf9d4267043a2fa5f41f4fdebc4a175e564e793)

Deployment

Docker Compose

Area

Playback and transcoding

Clients affected

  • Web UI

Client app and device

Silo Web 0.0.1 on Chrome 156.0.0.0 (Windows 10/11 x64)

Media and playback details

Container: MKV
Video: H.264 1080p
Audio: Japanese AAC 2.0
Play method: Direct Play

Relevant logs

time=2026-11-05T11:58:52.994Z level=INFO msg="apiv2 request" component=apiv2 request_id=290ce1d5afaee3f40c46d95e api_major=2 operation_id=updatePlaybackProgress method=POST path_pattern=/api/v2/playback/{session_id}/progress status=200 status_class=2xx error_code=none auth_class=session duration_ms=2 body_bytes=88 client_ip=[REDACTED] client_name="Silo Web" client_version=0.0.1 user_id=1

time=2026-11-05T11:59:52.999Z level=INFO msg="apiv2 request" component=apiv2 request_id=816b9d44d69a56de5e0860e0 api_major=2 operation_id=updatePlaybackProgress method=POST path_pattern=/api/v2/playback/{session_id}/progress status=401 status_class=4xx error_code=session_expired auth_class=anonymous duration_ms=0 body_bytes=223 client_ip=[REDACTED] client_name="Silo Web" client_version=0.0.1

time=2026-11-05T11:59:53.092Z level=INFO msg="apiv2 request" component=apiv2 request_id=a19864410fd9e2de10b0e932 api_major=2 operation_id=updatePlaybackProgress method=POST path_pattern=/api/v2/playback/{session_id}/progress status=403 status_class=4xx error_code=profile_verification_required auth_class=anonymous duration_ms=0 body_bytes=278 client_ip=[REDACTED] client_name="Silo Web" client_version=0.0.1

time=2026-11-05T11:59:56.131Z level=INFO msg="apiv2 request" component=apiv2 request_id=c318d965e2c2b6dac950d500 api_major=2 operation_id=stopPlayback method=DELETE path_pattern=/api/v2/playback/{session_id} status=422 status_class=4xx error_code=validation_failed auth_class=anonymous duration_ms=0 body_bytes=341 client_ip=[REDACTED] client_name="Silo Web" client_version=0.0.1

time=2026-11-05T12:00:36.414Z level=INFO msg="apiv2 request" component=apiv2 request_id=4728583a9b0d1f10e0d39d29 api_major=2 operation_id=startPlayback method=POST path_pattern=/api/v2/playback/start status=201 status_class=2xx error_code=none auth_class=session duration_ms=14 body_bytes=9851 client_ip=[REDACTED] client_name="Silo Web" client_version=0.0.1 user_id=1

Technical notes

Querying PostgreSQL playback_session_lifecycle during the incident showed both sessions persisted as live:

SELECT session_id, frontend, state, end_reason, started_at, activity_at, updated_at 
FROM playback_session_lifecycle 
WHERE state <> 'stopped';

Output:

              session_id              | frontend | state  | end_reason |          started_at           | activity_at |          updated_at           
--------------------------------------+----------+--------+------------+-------------------------------+-------------+-------------------------------
 4b8cb5ca-b18e-42e6-b7c1-a51d78e91cf4 | native   | paused |            | 2026-11-05 12:00:36.404439+00 |             | 2026-11-05 12:00:46.484006+00
 2c23e286-2ed6-4dfd-8aa4-7a2d7e27f18e | native   | paused |            | 2026-11-05 10:06:04.970172+00 |             | 2026-11-05 10:52:55.087173+00

GET /api/v2/admin/sessions payload for the zombie session showed "has_playback_control": false:

{
  "session_id": "2c23e286-2ed6-4dfd-8aa4-7a2d7e27f18e",
  "started_at": "2026-11-05T10:06:04.970Z",
  "updated_at": "2026-11-05T11:59:20.194Z",
  "is_paused": true,
  "has_playback_control": false
}

The session persisted in /api/v2/admin/sessions until explicitly terminated via POST /api/v2/admin/sessions/{id}/terminate.

AI involvement

  • AI harness: Google Antigravity
  • AI tool(s): Antigravity CLI
  • AI model(s): Gemini 3.8 Flash
  • AI involvement: AI-assisted
  • Independent or adversarial review:
    Forensic log and database audit conducted on a live production deployment (Silo-Server/silo-server). Traced correlation between client auth token expiration, failed DELETE /api/v2/playback/{session_id} HTTP 422 response, and playback_session_lifecycle persistence. Verified and confirmed by human operator.

Confirmations

  • I searched open and recently closed issues and pull requests, and this is not already reported
  • I reproduced this myself on a real deployment
  • Any logs provided are raw apart from marked redactions and are not AI-summarized

Activity

  1. added
    api-v2
    bug
    priority: P2
    on Nov 5, 2026
  2. rangoDJ commented on Nov 7, 2026

    @rangoDJ
    Contributor

    I tried to reproduce this on a local build of main (a52941174; the session code is unchanged since your baf9d426) and the paused session ended on its own.

    Steps: play a movie in the web player (direct play), pause it, wait 75 seconds so the paused progress reaches the server, then kill the browser so no DELETE /api/v2/playback/{session_id} is ever sent. That leaves the same state as your report: one session in playback_session_lifecycle with state = 'paused', listed in GET /api/v2/admin/sessions with is_paused: true, has_playback_control: false.

    I then checked the lifecycle row and the admin sessions list once a minute:

    02:36:42 +0m   paused  - upd=02:35:24   admin sessions: 1 [(paused, no control)]
    ...
    03:05:44 +29m  paused  - upd=02:35:24   admin sessions: 1 [(paused, no control)]
    03:06:44 +30m  stopped expired upd=03:06:41   admin sessions: 0
    

    The session was ended at 03:06:41 with end_reason = 'expired', 30 minutes after its last activity, and dropped out of the admin list. That is the paused-session grace (DefaultPausedSessionGrace in internal/playback/session.go, and pausedSessionGrace in internal/worker/cleanup.go), which is deliberately long so a paused stream survives a break.

    In your logs the old session's last request is the failed DELETE at 11:59:56, so it should have ended around 12:30. Was it still listed in Admin > Activity after that, or was it terminated before the 30 minutes were up? If it stayed longer, the server log around 12:30 (any expired or lifecycle sweep lines) and whether the old tab was still open would help narrow it down.

    The 422 on the DELETE is a separate detail: the request was anonymous after the token expired, so it could not have stopped the session either way.

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

    api-v2bugpriority: P2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions