Skip to content

Commit 09cc80f

Browse files
Merge commit from fork
chore:remove token request cache
2 parents b44aa97 + 75d8fd0 commit 09cc80f

File tree

4 files changed

+6
-218
lines changed

4 files changed

+6
-218
lines changed

src/server/client.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ import {
5252
} from "./session/abstract-session-store.js";
5353
import { StatefulSessionStore } from "./session/stateful-session-store.js";
5454
import { StatelessSessionStore } from "./session/stateless-session-store.js";
55-
import { TokenRequestCache } from "./token-request-cache.js";
5655
import {
5756
TransactionCookieOptions,
5857
TransactionStore
@@ -366,9 +365,6 @@ export class Auth0Client {
366365
private domain: string;
367366
#options: Auth0ClientOptions;
368367

369-
// Cache for in-flight token requests to prevent race conditions
370-
#tokenRequestCache = new TokenRequestCache();
371-
372368
constructor(options: Auth0ClientOptions = {}) {
373369
this.#options = options;
374370
// Extract and validate required options
@@ -643,14 +639,7 @@ export class Auth0Client {
643639
};
644640
}
645641

646-
// Execute the token request with caching to avoid duplicate in-flight requests
647-
return this.#tokenRequestCache.execute(
648-
() => this.executeGetAccessToken(req, res, options),
649-
{
650-
options,
651-
authorizationParameters: this.#options.authorizationParameters
652-
}
653-
);
642+
return this.executeGetAccessToken(req, res, options);
654643
}
655644

656645
/**

src/server/get-access-token-concurrent.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,11 @@ describe("Auth0Client - getAccessToken (Concurrent Calls)", () => {
266266
const accessToken1 = allAccessTokens.find((t) => t.audience === audience1);
267267
const accessToken2 = allAccessTokens.find((t) => t.audience === audience2);
268268

269-
// Expect only two tokens in the session, one per audience
270-
expect(allAccessTokens).toHaveLength(2);
269+
// NOTE: Without request deduplication (cache removed), concurrent calls with
270+
// identical parameters will each execute independently. This means we may get
271+
// multiple tokens saved for the same audience/scope combination, though they
272+
// should have the same value. The test now verifies that all tokens are present.
273+
expect(allAccessTokens.length).toBeGreaterThanOrEqual(2);
271274

272275
expect(accessToken1).toBeDefined();
273276
expect(accessToken1!.accessToken).toBe(token1);

src/server/token-request-cache.test.ts

Lines changed: 0 additions & 111 deletions
This file was deleted.

src/server/token-request-cache.ts

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)