You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the past, stateless sessions were problematic for logouts in our application due to the race condition between clearing the user agent's cookies & a concurrent network request that sets a valid cookie.
To solve this, we've implemented a custom session store using Redis (by following this example). As a result, the success rate of logouts have improved drastically -- however, I'm still noticing that logout will fail at times. This failure seems to happen at the application session layer since there is a "Successful Logout" log in our Auth0 tenant, but the application session is still active.
FWIW:
logout failure occurs roughly every 1 in 10 attempts
when logout fails, a subsequent logout seems to work fine
All that to say, I suspect there may be a race condition given the intermittent nature of the issue. Ideally, having stateful sessions should eliminate this issue.
Reproduction
Set up store with Redis (.get/set/delete methods)
Supply store as config.session to initAuth0
Invoke logout handler (/api/auth/logout)
Additional context
No response
nextjs-auth0 version
2.6.3
Next.js version
13.4.12
Node.js version
18.18.2
The text was updated successfully, but these errors were encountered:
If you have lots of sets on the session store for the same key concurrently with your delete, I can imagine that you would still have concurrency issues - where a request may start before the logout request, but it's set to the store may happen after the logout's delete (and so re-establish the session)
The easiest solution would be to limit the number of set's to the store. This SDK writes to the store on every request, but you can configure it not to do this (by disabling session.rolling) or you can configure it to roll the session more selectively (using session.autoSave = false and touchSession)
I see in connect-redis that there was also an attempt to modify the store (using a slow delete) to prevent this tj/connect-redis#333, but this was later reverted tj/connect-redis#347
Checklist
Description
In the past, stateless sessions were problematic for logouts in our application due to the race condition between clearing the user agent's cookies & a concurrent network request that sets a valid cookie.
To solve this, we've implemented a custom session store using Redis (by following this example). As a result, the success rate of logouts have improved drastically -- however, I'm still noticing that logout will fail at times. This failure seems to happen at the application session layer since there is a "Successful Logout" log in our Auth0 tenant, but the application session is still active.
FWIW:
All that to say, I suspect there may be a race condition given the intermittent nature of the issue. Ideally, having stateful sessions should eliminate this issue.
Reproduction
config.session
toinitAuth0
/api/auth/logout
)Additional context
No response
nextjs-auth0 version
2.6.3
Next.js version
13.4.12
Node.js version
18.18.2
The text was updated successfully, but these errors were encountered: