fix: Auto-retry with fresh session on 401 Unauthorized#1166
Open
Exotic209093 wants to merge 2 commits into
Open
fix: Auto-retry with fresh session on 401 Unauthorized#1166Exotic209093 wants to merge 2 commits into
Exotic209093 wants to merge 2 commits into
Conversation
When a REST API call returns 401 (session expired), attempt to retrieve a fresh session from the browser cookie before showing the error. This handles the case where the user has re-logged into Salesforce in another tab but the extension page still holds the old session. Closes tprouvot#1134
Author
|
I’ve updated the retry logic to handle both auth modes now. On a 401, it first checks whether a newer connected-app access token is already available in localStorage, and if not it falls back to fetching a fresher Salesforce sid session from the background script. I also changed the retry to replay the original request cleanly instead of reusing the mutated URL/body from the failed attempt. I tested the two cases locally:
One limitation remains: this does not silently mint a brand new connected-app token if the stored token is expired and no newer token exists yet. In that case it still falls back to the existing "Generate New Token" flow. |
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.
Summary
How it works
chrome.runtime.sendMessageThe retry is protected by a
_sessionRetriedflag to prevent infinite loops.Test Plan
Closes #1134