Repository navigation
Conversation
When the stored bearer stops being honoured (sessions expire after 30 days unused, or get revoked), tv-native has no 401 handling: the guide shows "No channels yet — once channels are set up on your server…", which reads as an empty server, and the only way out is Account → Sign out by hand. tv-web and tv-tauri already sign out on a guide 401. This is the 401 piece trimmed from Quixomatic#63 for scope, brought back on its own: - api.ts: a 401 clears the token (server URL kept) and routes to /login. Network / 5xx / 403 failures never touch it, and a 401 is ignored if the token or server has changed since the request went out. - auth.ts: token writes go through one queue; invalidateToken re-checks the rejected token inside it, so a late 401 can't delete a login that landed between the check and the delete. - 11 bun regressions (fresh process per phase, only storage/native/network substituted), adapted from Quixomatic#63's suite to the current RN Settings store. Co-authored-by: SHRIVES93 <75397028+SHRIVES93@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
Author
|
Cross-ref: #70 fixes the same failure, a TV client not recovering once the server rejects its session (401), on tv-roku, where it also left Settings/Account unusable. The two PRs are independently scoped and can be reviewed and merged separately; neither depends on the other. |
4 of 8 tasks
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
This is the 401 auto-logout trimmed from #63 for scope ("happy to look at any of them as a separate PR"), brought back as its own focused change. It was reworked against current
main, not cherry-picked.The defect: once the stored bearer stops being honoured (Better Auth sessions expire after 30 days unused, or get revoked), tv-native never recognises the 401. The guide falls through to the empty state, "No channels yet — Once channels are set up on your server, they'll appear here", which reads as an empty server rather than a dead session. The only way out is to go to Account → Sign out by hand. tv-web and tv-tauri already sign out on a guide 401 (
guide-screen.tsx); tv-native is the odd one out. We hit the same failure on Roku (#70), where the sidebar bug made it a hard trap. Apple TV's sidebar doesn't have that bug.This change:
api.ts: a 401 clears the token, keeps the server URL and replaces to/login. Network failures, 5xx and 403 never touch the credentials. A 401 is ignored if the token or the server changed after the request went out, so a late response from before a fresh login, or from the previous server, can't sign the user out.auth.ts: token writes go through one queue, andinvalidateTokenre-checks the rejected token inside it. Without the queue there's a window between the outer check and the async delete where a concurrent login can be wiped. fix(tvos): persist server configuration and sessions #63 listed this serialization as a separate trimmed item, but the stale-401 guard depends on it. The mutation check below shows that.pnpm --filter tv-native test. Each phase runs in a fresh process; only storage, native modules and network are substituted, andauth/cred-store/session-storage/apiare the production modules. They're adapted from fix(tvos): persist server configuration and sessions #63's suite: that suite mocked the dropped Swift module and the removedstartup.ts/session-route.ts, and now mocks RNSettings. It's scoped to the 401 lifecycle.Not included (the other pieces trimmed from #63): the startup retry screen and the storage-error UI on sign-out / Change Server. The #63 CI workflow isn't included either.
Area
Testing
pnpm --filter tv-native test: 11 pass, 0 fail. Covered:/login, and that survives a restart;main: 4 fail (the 401 and concurrency cases) and 7 pass (the guards). The suite catches the defect.pnpm --filter tv-native check-types: clean.router.replace("/login")from inside the request path, and the real 401 → Login transition, still need a check on hardware.Checklist
pnpm check-types, relevantbuild).envvalues committedCredit to @SHRIVES93: the design and the original suite are from #63.
🤖 Generated with Claude Code