fix(jellyfin): drain only the stopped playback's reports in the generic stop

The generic stop waited for every tracked report, including progress for
the next queued episode, which could delay the stop and the start waiting
on it. It now waits only for reports tagged with the playback it stops.
This commit is contained in:
sudacode committed 2026-11-23 02:27:54 -08:00
1 parent 0cae6b96fb
commit 24cd8cae88
2 files changed
+28 -1

No files matched your search

@@ -540,3 +540,29 @@ test('createReportSupersededJellyfinPlaybackHandler waits only for the supersede
assert.deepEqual(events, ['old progress done', 'stopped:item-1@14100000000']);
});
test('createReportJellyfinRemoteStoppedHandler is not held by reports for another playback', async () => {
const tracker = createJellyfinRemoteReportTracker();
// The next episode's progress stays in flight for the whole test.
tracker.track(new Promise<void>(() => {}), makePlayback({ itemId: 'item-2' }));
let stopped = false;
const reportStopped = createReportJellyfinRemoteStoppedHandler(
makeStoppedDeps({
getActivePlayback: () =>
makePlayback({
loadedMediaPath: 'https://stream.example/item-1.m3u8',
lastKnownPositionSeconds: 30,
reporter: makeReporter({
reportStopped: async () => {
stopped = true;
},
}),
}),
reportTracker: tracker,
}),
);
await reportStopped();
assert.equal(stopped, true);
});
+2 -1
View File
@@ -277,7 +277,8 @@ export function createReportJellyfinRemoteStoppedHandler(deps: JellyfinRemoteSto
// Clear before any network call so progress ticks fired during the stop find nothing to
// report, then let reports already in flight finish so none can arrive after the stop.
deps.clearActivePlayback();
await deps.reportTracker?.settled();
// Only this playback's reports: mpv may already be reporting the next episode.
await deps.reportTracker?.settled(playback);
try {
// mpv may have moved to another file while reports drained, and its position would then
// overwrite this item's resume point. Off its file, the last position observed for it