'next-auth getSession serverside doesn't trigger visibilityChange event to refresh token

Using "next-auth": "^4.2.1", with CredentialsProvider. Already implemented token rotation and is working alright. On the client side, useSession hook refreshes the session token when it expires. I need to obtain the token to use in my GraphQL query in getServerSideProps like this;

  const session = await getSession({
    req,
    broadcast: true,
    triggerEvent: true,
    event: 'visibilitychange',
  });

  if (!session) {
    return {
      redirect: {
        destination: '/login',
        permenant: false,
      },
    };
  }

  const token = await getToken({
    req,
    secret: process.env.TOKEN_SECRET,
    raw: true,
  });

As long as I keep the same browser open, this works fine. However, If I close the browser, and come back after token expiresIn period, open a new browser and navigate directly to my page http://localhost:3000/cities, old token, which was in the session cookie when I've closed the browser, returns from getToken. I'm expecting calling getSession with trigger & event parameters would force jwt process and creates a new token, as in client side. Am I missing anything? What are the purpose of event, triggerEvent & broadcast parameters then?
Thanks in advance



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source