Skip to content

Bug: TypeError on sessions without active playback - Container.toUpperCase() on undefined #490

@judarange

Description

@judarange

Bug Description

The "Now Playing" / "Activity" section shows "No playback found" even when there are active sessions streaming content. The browser console shows:

TypeError: Cannot read properties of undefined (reading 'toUpperCase')

Root Cause

In the minified frontend code (/app/frontend/dist/assets/index-6d3878d7.js), around position 24900-25300, there's code that calls .toUpperCase() on Container fields without null checks:

a=o=>{
  let g="";
  return o.TranscodingInfo && (g=` -> ${o.TranscodingInfo.Container.toUpperCase()}`),
  `${o.NowPlayingItem.Container.toUpperCase()}${g}`
}

When a session doesn't have an active NowPlayingItem or TranscodingInfo, or when these objects exist but Container is undefined, the code crashes.

Additionally, PlayState.PlayMethod can be undefined for idle sessions.

Affected Version

Jellystat v1.1.7

Workaround / Proposed Fix

Add data sanitization in ActivityMonitor.js before sending session data to the frontend via WebSocket:

function sanitizeSessionData(sessions) {
  if (!Array.isArray(sessions)) return [];
  return sessions.map(session => ({
    ...session,
    Client: session.Client || "",
    DeviceName: session.DeviceName || "",
    UserName: session.UserName || "",
    PlayState: session.PlayState 
      ? { ...session.PlayState, PlayMethod: session.PlayState.PlayMethod || "" }
      : { PlayMethod: "", IsPaused: false },
    NowPlayingItem: session.NowPlayingItem 
      ? { ...session.NowPlayingItem, Container: session.NowPlayingItem.Container || "" }
      : null,
    TranscodingInfo: session.TranscodingInfo 
      ? { ...session.TranscodingInfo, Container: session.TranscodingInfo.Container || "" }
      : null
  }));
}

Then use it before sending updates:

sendUpdate("sessions", sanitizeSessionData(apiSessionData));

Alternatively, fix the frontend to add null checks before calling .toUpperCase().

Steps to Reproduce

  1. Have multiple Jellyfin clients connected (some actively playing, some idle)
  2. Open Jellystat dashboard
  3. Check browser console for TypeError
  4. "Now Playing" section shows no playback even though streams are active

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