diff --git a/recipe/session/recipeImplementation.go b/recipe/session/recipeImplementation.go index d707a721..d154981c 100644 --- a/recipe/session/recipeImplementation.go +++ b/recipe/session/recipeImplementation.go @@ -63,6 +63,10 @@ func getJWKSFromCacheIfPresent() *sessmodels.GetJWKSResult { // from the cores again after the entry in the cache is expired if (currentTime - jwksCache.LastFetched) < JWKCacheMaxAgeInMs { if supertokens.IsRunningInTestMode() { + if len(returnedFromCache) == cap(returnedFromCache) { // need to clear the channel if full because it's not being consumed in the test + close(returnedFromCache) + returnedFromCache = make(chan bool, 1000) + } returnedFromCache <- true } @@ -116,6 +120,10 @@ func getJWKS() (*keyfunc.JWKS, error) { jwksCache = &jwksResult if supertokens.IsRunningInTestMode() { + if len(returnedFromCache) == cap(returnedFromCache) { // need to clear the channel if full because it's not being consumed in the test + close(returnedFromCache) + returnedFromCache = make(chan bool, 1000) + } returnedFromCache <- false }