n1ru4l
09/09/2022, 12:49 PM[object Object]
logs, we pinned it down to the following code within our Next.js application:
const { backendConfig } = await import('@/config/backend-config');
const SupertokensNode = await import('supertokens-node');
const Session = await import('supertokens-node/recipe/session');
SupertokensNode.init(backendConfig());
// this throws the error
const session = await Session.getSession(context.req, context.res, { sessionRequired: false });
After debugging the error and manually printing it this is the actual error:
SessionError {
type: 'TRY_REFRESH_TOKEN',
message: 'Access token has expired. Please call the refresh API',
payload: undefined,
errMagic: 'ndskajfasndlfkj435234krjdsa',
fromRecipe: 'session'
}
It seems like the error is not properly stringified (does not correctly extend/implement the Error class) as it seems to not pass the nextjs
isError
check?
Here is our debugging branch for figuring this out: https://github.com/kamilkisiela/graphql-hive/commit/63e66ab48335a3173d870c07a9510734b7f3c4af
Furthermore, as this appears over and over again we also believe that this error is not properly handled on the frontend (supertokens-auth-react
).
I assume that if this happens the session cookies should be unset.
Happy to open an issue on GitHub if there is no clear solution to this issue!rp_st
09/09/2022, 1:22 PMrp_st
09/09/2022, 1:25 PMn1ru4l
09/09/2022, 1:25 PMrp_st
09/09/2022, 1:26 PMn1ru4l
09/09/2022, 1:26 PMn1ru4l
09/09/2022, 1:26 PMrp_st
09/09/2022, 1:26 PMrp_st
09/09/2022, 1:27 PMn1ru4l
09/09/2022, 1:31 PMn1ru4l
09/09/2022, 1:32 PMgetServerSideProps
so I assume it should attempt trying to create a new access token... but I am unsure...n1ru4l
09/09/2022, 1:35 PMrp_st
09/09/2022, 1:36 PMrp_st
09/09/2022, 1:36 PMrp_st
09/09/2022, 1:37 PM