Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve plex user mismatch due to caching issues #1242

Merged
merged 3 commits into from
Jan 12, 2025

Conversation

fallenbagel
Copy link
Owner

@fallenbagel fallenbagel commented Jan 11, 2025

Description

This PR addresses an issue introduced with #840 where cached responses for PlexTV API requests returned incorrect user data when multiple users were logged in (when previous cache existed). This was caused by a shared cache key that did not account for differences in auth tokens, i.e X-Plex-Token. The serializeCacheKey method should now include headers in the cache key generation to ensure unique cache keys. This should fix the plex user mismatch that occurred due to the same cache key being used without accounting for the difference in auth token.

(Note)
The reason this did not occur on axios was because it was creating a new axios instance in the constructor with its own base config for each user/token, while with fetch it was reusing the same instance with shared cache.

PR can be tested with the tag preview-fix-plex-user-mismatch

Screenshot (if UI-related)

To-Dos

  • Successful build pnpm build
  • Translation keys pnpm i18n:extract
  • Database migration (if required)

Issues Fixed or Closed

This commit addresses an issue where cached responses for PlexTV API
requests could return incorrect user data when multiple users were logged in.
This was caused by a shared cache key that did not account for differences
in auth tokens, i.e `X-Plex-Token`. The `serializeCacheKey` method should
now include headers in the cache key generation to ensure unique cache keys.
This should fix the plex user mismatch that occurred due to the same
cache key being used without accounting for the difference in auth
token.

fix #1227
@fallenbagel fallenbagel added the preview PRs deployed for testing with tag `:preview-prxx` label Jan 11, 2025
gauthier-th
gauthier-th previously approved these changes Jan 11, 2025
server/api/externalapi.ts Show resolved Hide resolved
server/api/externalapi.ts Outdated Show resolved Hide resolved
server/api/externalapi.ts Outdated Show resolved Hide resolved
server/api/externalapi.ts Outdated Show resolved Hide resolved
@fallenbagel fallenbagel force-pushed the fix-plex-user-login-cache branch from a9ab988 to 1d183c5 Compare January 11, 2025 15:16
@fallenbagel fallenbagel merged commit 131a5a2 into develop Jan 12, 2025
7 checks passed
@fallenbagel fallenbagel deleted the fix-plex-user-login-cache branch January 12, 2025 01:51
@fallenbagel
Copy link
Owner Author

🎉 This PR is included in version 2.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview PRs deployed for testing with tag `:preview-prxx` released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jellyseer will log into the wrong account after a first login with plex is done
2 participants