Hello there! Sometimes I get an error that is triggered during session check:
Copy code
if (resp.headersSent) {
throw new STError({
message: 'RESPONSE_SENT',
type: 'RESPONSE_SENT',
});
}
(from the NestJS guide)
It seems to happen when session is getting old (like an hour).
Why is this check there? When could it happen?
r
rp_st
08/10/2023, 5:20 AM
hey @jam_nside this happens when the access token has expired. In this case, our middleware sends a response directly to the client, and thats why we have this.
j
jam_nside
08/10/2023, 5:23 AM
Alright, makes sense. How to gracefully handle this case to ask for a relogin?
r
rp_st
08/10/2023, 5:23 AM
the frontend sdk should try and refresh on its own
Thank you rp. For the record, my mistake was that I had a catch-everything NestJS filter below the SupertokensExceptionFilter, while it needs to be declared first (counter-intuitive according to me, but hey): https://docs.nestjs.com/exception-filters#catch-everything
So my filter was catching SupertokensErrors instead of going through the expected errorHandler.
SuperTokens is an open source authentication solution offering features like: Different types of login: Email / password, Passwordless (OTP or Magic link based).