Skip to content

Intermittent Logout Failure with Custom Session Store #1531

Closed
@k-1ee

Description

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:

  • 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

  1. Set up store with Redis (.get/set/delete methods)
  2. Supply store as config.session to initAuth0
  3. 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

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions