We also found another scenario where our logs showed a lot of
[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!