Skip to content

feat: Refresh PO tokens which are not accepted - #10151

Open
FishDomination wants to merge 2 commits into
FreeTubeApp:developmentfrom
FishDomination:refresh-po-token
Open

FishDomination wants to merge 2 commits into
FreeTubeApp:developmentfrom
FishDomination:refresh-po-token

Conversation

@FishDomination

@FishDomination FishDomination commented Nov 20, 2026 •

Copy link
Copy Markdown

Pull Request Type

  • Bugfix
  • Feature Implementation
  • Documentation
  • Other

Related issue

closes #10024
closes #10090
#7921 (maybe?)

Description

When using a VPN Youtube frequently does not accept the generated PO Token. This causes the player to spam retry until the server sends a backoff timeout which then loops up to 3 times before the player reloads and a new token is generated. All these reloads are unnecessary because the PO token is already rejected.
This change adds an additional token refresh as soon as a request is rejected. It also waits in the retries until the new token is generated.
I also lowered the max retry count to 20 from 100 because i once saw while debugging that over 50 requests were sent in ~2 seconds.

I ran a local build with this change a few days and i notice almost zero player reloads and when then at most once. "Remaining SABR Backoff" Toasts still popt up on most videos.
Before i sometimes had to switch vpn servers because videos were stuck in a SABR Toast and player reload loop.

Testing

  • Use a VPN (i am using Proton VPN)
  • Watch any Video with the VPN active
  • Observe SABR Toasts and player reloads
  • You may need to switch between different VPN servers, my experience shows that each 200 id groups (0-199, 200-399, ...) seem to be treated as one by filters

Desktop

  • OS: CachyOS
  • OS Version: Kernel 7.3.3-1-cachyos
  • FreeTube version: 0.25.0

@github-actions github-actions Bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label Nov 20, 2026
@FreeTubeBot
FreeTubeBot enabled auto-merge (squash) November 20, 2026 22:20
if (!streamProtectionStatus) break

if (streamProtectionStatus.status === 2 || streamProtectionStatus.status === 3) {
refreshPoTokenFor(currentState)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refreshPoTokenFor is a promise, if streamProtectionStatus.status=3 it will also set invalidPoToken = true, no matter where the execution of refreshPoTokenFor is
Is it intended?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, i missed that. I moved the refresh call into the retry block. The call happening in the reader was also not optimal.
On thing my fixup changed is that it expects only 1 stream protection status per response. My tests never showed more than one in a response, can you confirm that holds?

auto-merge was automatically disabled November 21, 2026 09:57

Head branch was pushed to by a user without write access

@FreeTubeBot
FreeTubeBot enabled auto-merge (squash) November 21, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: waiting for review For PRs that are complete, tested, and ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Many breaks at Video playing (SABR reloads) [Bug]: Uptick in reloading due to SABR request messages

2 participants