Closed RoushanSingh-dot closed 5 months ago
Steps to reproduce:
call this function and log the result:
let session = await Session.getSession(req, res); console.log(session);
Pass 'Cookie' with invalid data. Or any expired access token.
It is supposed to give error but if we don't wrap the above code inside try-catch, the server crashes.
In express, you can't directly throw errors in the in the API handler code, but pass it to the next
function (the third param passed to the handler function). If you do that this works as expected.
On a related note, in most situations we recommend using the verifySession
middleware instead of calling getSession
directly.
Related discord thread: https://discordapp.com/channels/603466164219281420/1199674501093412914
If the session is expired, supertokens is logging error failed to verify access token but the server is crashing after that call.
If we wrap this code inside try catch, then it is working absolutely fine.
So, the issue is error handler not handling this error.