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 invalid token triggering token refresh in an infinite loop #3056

Merged
merged 3 commits into from Mar 5, 2024

Conversation

nuno-vieira
Copy link
Member

@nuno-vieira nuno-vieira commented Mar 4, 2024

🔗 Issue Links

Resolves https://github.com/GetStream/ios-issues-tracking/issues/739
Related to #3032

🎯 Goal

Fix invalid token calling token refresh in an infinite loop

🛠 Implementation

We were incorrectly triggering a token refresh whenever we received an invalid token. The token refresh should only be triggered when the token is expired. If a token is invalid, it is because of a programming error, so if we retry it, it will be in an infinite loop:

  1. Get Token
  2. Signature is Invalid
  3. Refresh Token
  4. Signature is Invalid
  5. Go to 3.

With this change, if a token is invalid, we simply stop retrying, and a manual retry should be done.

🧪 Manual Testing Notes

  1. Open Demo App Configuration
  2. Tap on tokenRefreshDetails
  3. Add an invalid secret to the token
  4. Open the app
  5. The channel list fetch should fail, and you should not see a loop of "Token refreshing" in the console log.

☑️ Contributor Checklist

  • I have signed the Stream CLA (required)
  • This change follows zero ⚠️ policy (required)
  • This change should be manually QAed
  • Changelog is updated with client-facing changes
  • New code is covered by unit tests
  • Comparison screenshots added for visual changes
  • Affected documentation updated (docusaurus, tutorial, CMS)

@nuno-vieira nuno-vieira added 🐞 Bug An issue or PR related to a bug 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK labels Mar 4, 2024
@nuno-vieira nuno-vieira requested a review from a team as a code owner March 4, 2024 15:44
@nuno-vieira nuno-vieira changed the title Fix invalid token calling token refresh in an infinite loop Fix invalid token triggering token refresh in an infinite loop Mar 4, 2024
Copy link

sonarcloud bot commented Mar 4, 2024

Copy link
Contributor

@martinmitrevski martinmitrevski left a comment

Choose a reason for hiding this comment

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

LGTM ✅

@nuno-vieira nuno-vieira merged commit 44527c8 into develop Mar 5, 2024
15 checks passed
@nuno-vieira nuno-vieira deleted the fix/invalid-token-infinite-retry-loop branch March 5, 2024 11:15
@testableapple testableapple mentioned this pull request Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 Bug An issue or PR related to a bug 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants