fix: avoid the race condition when ProtectedRoute
is used
#118
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.
Purpose
This pull request introduces improvements to the React client session management and loading state handling, as well as some code style and consistency updates in workflow and script files. The most significant changes focus on making session updates more robust and preventing race conditions during authentication, along with minor refactoring for clarity and maintainability.
React Client & Provider Improvements
isUpdatingSession
flag and logic inAsgardeoProvider.tsx
to prevent race conditions and ensure accurate loading and sign-in state during critical session updates such as sign-in, silent sign-in, and organization switching. This helps avoid UI inconsistencies, especially in protected routes. [1] [2] [3] [4] [5] [6] [7] [8] [9]AsgardeoReactClient.ts
(getDecodedIdToken
,getUserProfile
,getCurrentOrganization
,getAccessToken
) withwithLoading
to ensure consistent loading state management. [1] [2] [3] [4]isSignedIn
method to make it explicitly async and useawait
.IdToken
inAsgardeoProvider.tsx
.Workflow and Script Consistency
title
andcommit
fields in.github/workflows/release.yml
for consistency, and reformatted theif
condition for readability. [1] [2]scripts/aggregate-changelogs.js
for better readability and consistency: collapsedSKIP_PACKAGES
to a single line, converted some arrow functions to a more concise form, and adjusted function closing brackets. [1] [2] [3]Related Issues
@asgardeo/react
&@asgardeo/nextjs
#81Related PRs
Checklist
Security checks