/api/auth/me gives 500 (FUNCTION_INVOCATION_FAILED) sometimes

Hi guys,

I’m getting a concerning error on my server less functions.

[GET] /api/auth/me
2023-01-30T13:51:52.572Z	911167ff-8f2e-4e19-9a8c-713c1592d2b7	ERROR	Unhandled Promise Rejection 	{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: timeout of 3000ms exceeded","trace":["Runtime.UnhandledPromiseRejection: Error: timeout of 3000ms exceeded","    at process.<anonymous> (file:///var/runtime/index.mjs:1194:17)","    at process.emit (node:events:525:35)","    at process.emit (node:domain:489:12)","    at emit (node:internal/process/promises:149:20)","    at processPromiseRejections (node:internal/process/promises:283:27)","    at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"]}
[ERROR] [1675086712573] LAMBDA_RUNTIME Failed to post handler success response. Http response code: 400.
RequestId: 2d774220-9e03-445f-ac92-f8babf16565f Error: Runtime exited without providing a reason

This error comes only sometimes (every 3rd time or something) and does not have any logic to it.
I’m using the withMiddlewareAuthRequired function but it also does not work with the withAuthRequiredFunction in the getServerSideProps. I don’t face the issue when authenticating client side, but we need server side authentication.
It also looks like a timeout error, but the function just fails. I know that because I get the FUNCTION_INVOCATION_FAILED response.

Unfortunately I do not have more details. The only thing I can tell is that it also sometimes happens with the /api/users/USERID call.

I’m hosted on Vercel in Germany and we have our Auth0 also in Europe.