Channel folders show no items on first browse when requests overlap
Description of the bug
When a folder of a channel plugin is opened for the first time, it can show no items, or only some of them. Reloading the page shows them all. It is most visible with series and seasons provided by a channel (ChannelFolderType.Series / Season), where seasons or episodes are missing until a reload.
The cause is a race in ChannelManager.GetChannelItemsInternal:
- Opening a folder makes the client send several requests which each list the folder, e.g. the item itself and its seasons.
- The first request takes
_resourcePool, gets the items from the channel, writes the cache file, releases the lock, and only then creates the items in the library (GetChannelItemEntityAsync). - Another request which waited on the lock, or arrived after it was released, finds the cache fresh, skips the update and reads the library with
GetItemsResultwhile the items are not there yet.
The window grows with the time the channel takes to answer, since requests pile up on the lock meanwhile. It also means that if creating the items fails, the cache is already written and the folder stays incomplete for the 3 hours of CacheLength.
Users of the Xtream plugin report the symptom in https://github.com/Kevinjil/Jellyfin.Xtream/issues/253 ("Many Series seasons have no episodes (until Refresh Metadata)").
Reproduction steps
- Install a channel plugin which provides series, e.g. Jellyfin.Xtream, with a provider that takes a moment to answer.
- Open a series which has never been browsed.
- Open one of its seasons.
What is the current bug behavior?
The series shows no seasons, or the season shows no episodes, or only some of them. Reloading the page shows all of them.
What is the expected correct behavior?
All seasons and episodes show the first time the series or season is opened.
Jellyfin Server version
12.1
Specify commit id
No response
Specify unstable release number
No response
Specify version number
No response
Specify the build version
12.1
Environment
- OS: Debian 13 (official jellyfin-server 12.1+deb13 package)
- Linux Kernel:
- Virtualization:
- Clients: Web
- Browser:
- FFmpeg Version:
- Playback Method:
- Hardware Acceleration:
- CPU Model:
- GPU Model:
- Plugins: Jellyfin.Xtream 0.8.1.1
- Reverse Proxy:
- Base URL:
- Networking:
- External Integrations:Jellyfin logs
Nothing is logged: the requests succeed, the items are only missing from their response.FFmpeg logs
No response
Client / Browser logs
No response
Relevant screenshots or videos
No response
Additional information
The bug is also present on master at 3655c6861d, where the relevant code is unchanged.
Source: jellyfin/jellyfin