File tree Expand file tree Collapse file tree 1 file changed +2
-0
lines changed
packages/clerk-js/src/core/resources Expand file tree Collapse file tree 1 file changed +2
-0
lines changed Original file line number Diff line number Diff line change @@ -377,6 +377,7 @@ export class Session extends BaseResource implements SessionResource {
377377 const tokenId = this . #getCacheId( template , organizationId ) ;
378378
379379 const cachedEntry = skipCache ? undefined : SessionTokenCache . get ( { tokenId } , leewayInSeconds ) ;
380+ // Dispatch tokenUpdate only for __session tokens with the session's active organization ID, and not JWT templates
380381 const shouldDispatchTokenUpdate = ! template && organizationId === this . lastActiveOrganizationId ;
381382
382383 if ( cachedEntry ) {
@@ -422,6 +423,7 @@ export class Session extends BaseResource implements SessionResource {
422423 const params : Record < string , string | null > = template ? { } : { organizationId } ;
423424
424425 const tokenResolver = Token . create ( path , params , skipCache ) ;
426+ // Cache the promise immediately to prevent concurrent calls from triggering duplicate requests
425427 SessionTokenCache . set ( { tokenId, tokenResolver } ) ;
426428
427429 return tokenResolver . then ( token => {
You can’t perform that action at this time.
0 commit comments