Skip to content

Commit 9f338f4

Browse files
committed
wip
1 parent 67dd241 commit 9f338f4

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

packages/clerk-js/src/core/resources/Session.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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 => {

0 commit comments

Comments
 (0)