auth0-spa-js icon indicating copy to clipboard operation
auth0-spa-js copied to clipboard

checkSession -> _getTokenSilently with ignoreCache: true subsequent slow loading time

Open halafi opened this issue 2 years ago • 0 comments

Describe the problem

Subsequent checkSession call is taking significantly longer than first time load.

I have run into this issue across auth0 discussion boards with no real solution:

  • https://community.auth0.com/t/auth0-js-checksession-slow/30309
  • https://community.auth0.com/t/help-checksession-function-take-10-seconds-to-execute/28370
  • ...

If a checkSession call is made triggering _getTokenSilently with ignoreCache: true is acquires lock -> GET_TOKEN_SILENTLY_LOCK_KEY, however it doesn't release it on reload of the page with can result in slower load after the reload due to the lock not being released (inability to acquire).

What was the expected behavior?

I would expect for example onbeforeunload releasing the lock on reload.

Reproduction

  • Step 1: on page load trigger ( checkSession -> _getTokenSilently ) call with ignoreCache: true
  • Step 2: after 1 second reload
  • Step 3: on subsequent page load there might be 5-10 sec additional delay if the lock cannot be acquired

Environment

  • Version of auth0-spa-js used: ^1.19.4
  • Which browsers have you tested in? Version 103.0.5060.134 (Official Build) (arm64)
  • Which framework are you using, if applicable (Angular, React, etc): React

halafi avatar Aug 01 '22 11:08 halafi