Getting random "Invalid State" error for some visitors on callback redirection

Ok hello.

My flow is like this:

  1. The user goes to domain.com (my app)
  2. I’m generating a log in link and I’m redirecting the user to that log in link. All works fine to this point.
  3. The user logs in and now he’s redirected back to domain.com with the callback in the url. So at this point i’m calling my checkUrlForAuthRedirectQuery() function
  4. That function throws “invalid state” from the SDK.

I cannot reproduce this bug, I know that this bug may happen when the callback may have an invalid / expired link but that’s not the case. These users are entering my site for the first time and getting that

This is my check callback url function:

const checkUrlForAuthRedirectQuery = async () => {
    try {
        const auth0 = await getAuth0Client();
        await auth0.handleRedirectCallback();

        const tokenClaims = await auth0.getIdTokenClaims();

        // Call login API to add cookie
        await makeEndpointRequest(
            'Login',
            {},
            {
                headers: {
                    Authorization: `Bearer ${tokenClaims.__raw}`,
                },
            },
        );

        router.push('/home');
       
    } catch (err) {
        await logError(`CHECK_AUTH0_REDIRECT_QUERY_URL`, err);
    }
};