Skip to content

Commit a856b08

Browse files
committed
fix: invalidate rejected SABR playback context
1 parent 1c8bcbf commit a856b08

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/main/kotlin/dev/typetype/server/routes/SabrPlaybackRecovery.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ internal class SabrPlaybackRecovery(private val sessionStore: SabrSessionStore)
1818
return RETRY_FRESH_SESSION
1919
}
2020
if (failure.contains("protected no-media")) {
21+
sessionStore.invalidatePlaybackInfo(holder.key.videoId)
2122
return RETRY_FRESH_SESSION
2223
}
2324
if (failure.contains("SABR demand stalled")) {

src/test/kotlin/dev/typetype/server/routes/SabrPlaybackRecoveryTest.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,16 @@ class SabrPlaybackRecoveryTest {
9090
}
9191

9292
@Test
93-
fun `protected no-media keeps the selected format on a fresh session`() = runTest {
93+
fun `protected no-media invalidates playback info and keeps the selected format`() = runTest {
9494
val holder = mockk<SabrSessionHolder>()
95-
val recovery = SabrPlaybackRecovery(mockk())
95+
val store = mockk<SabrSessionStore>()
9696
every { holder.terminalFailure() } returns "video:299:12 status=3 protected no-media"
97+
every { holder.key } returns SabrSessionKey("video", "user", 140, null, 299, 0L)
98+
coEvery { store.invalidatePlaybackInfo("video") } returns Unit
99+
val recovery = SabrPlaybackRecovery(store)
97100

98101
assertEquals("retry_fresh_session", recovery.action(holder))
99102
assertEquals(emptyList<Int>(), recovery.retryVideoItags())
103+
coVerify(exactly = 1) { store.invalidatePlaybackInfo("video") }
100104
}
101105
}

0 commit comments

Comments
 (0)