Skip to content

Commit 5c58bd4

Browse files
fix(tests): sso token cache race condition #3001
Problem: Unit tests would sporadically fail due to cache not being cleared when expected. Certain methods called async clear() without waiting, and the checks in the test executed before the clear() could complete. Solution: Add 'await' to the impacted clear() calls. Signed-off-by: Nikolas Komonen <[email protected]>
1 parent 393f0d9 commit 5c58bd4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/credentials/sso/ssoAccessTokenProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class SsoAccessTokenProvider {
104104
return await this.authorize(registration)
105105
} catch (err) {
106106
if (err instanceof SSOOIDCServiceException && isClientFault(err)) {
107-
this.cache.registration.clear(cacheKey)
107+
await this.cache.registration.clear(cacheKey)
108108
}
109109

110110
throw err
@@ -119,7 +119,7 @@ export class SsoAccessTokenProvider {
119119
return this.formatToken(response, registration)
120120
} catch (err) {
121121
if (err instanceof SSOOIDCServiceException && isClientFault(err)) {
122-
this.cache.token.clear(this.tokenCacheKey)
122+
await this.cache.token.clear(this.tokenCacheKey)
123123
}
124124

125125
throw err

0 commit comments

Comments
 (0)