Skip to content

cache client instances in Auth0ClientFactory to prevent duplicate state#1506

Merged
subhankarmaiti merged 1 commit intomasterfrom
fix/factory-client-caching
Apr 9, 2026
Merged

cache client instances in Auth0ClientFactory to prevent duplicate state#1506
subhankarmaiti merged 1 commit intomasterfrom
fix/factory-client-caching

Conversation

@subhankarmaiti
Copy link
Copy Markdown
Contributor

Adds instance caching to Auth0ClientFactory (both native and web) so that multiple calls to createClient() with the same domain|clientId return the same IAuth0Client instance.

Problem

When Auth0Provider unmounts and remounts (e.g., navigation changes, React Suspense boundaries, or Fast Refresh), a brand-new client was created each time. This could lead to:

  • Duplicate refresh-token exchanges racing against each other
  • Inconsistent in-flight state between the Auth0 class singleton and the Auth0Provider hook
  • Wasted native bridge allocations

Verification

  • The Auth0 class and Auth0Provider now resolve to the same underlying client when configured with matching domain/clientId, ensuring credentials saved via one path are immediately visible to the other.

@subhankarmaiti subhankarmaiti requested a review from a team as a code owner April 9, 2026 09:57
@subhankarmaiti subhankarmaiti changed the title Cache client instances in Auth0ClientFactory to prevent duplicate state cache client instances in Auth0ClientFactory to prevent duplicate state Apr 9, 2026
@subhankarmaiti subhankarmaiti merged commit df58c80 into master Apr 9, 2026
4 checks passed
@subhankarmaiti subhankarmaiti deleted the fix/factory-client-caching branch April 9, 2026 10:10
@subhankarmaiti subhankarmaiti mentioned this pull request Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants