codeforces-readme-stats icon indicating copy to clipboard operation
codeforces-readme-stats copied to clipboard

FUNCTION_INVOCATION_TIMEOUT Error

Open RedHeadphone opened this issue 3 years ago • 1 comments

Whenever Codeforces contests are live, their API gets slow, and as a result, my API gives FUNCTION_INVOCATION_TIMEOUT error because of the Vercel limits.

One solution to that can be a custom API cache adapter at the backend to cache codeforces API that saves the last 200 response data separately along with a time limit for temporary cache. So when data is not found in the temporary cache, it calls API, and if API gives an error or takes more than some seconds, it returns the last 200 response data.

RedHeadphone avatar Mar 29 '23 17:03 RedHeadphone

Possible way to implement it: https://stackoverflow.com/questions/56029972/return-for-function-after-certain-execution-time/56062464#56062464

RedHeadphone avatar Oct 14 '23 06:10 RedHeadphone

Also move whole API calling into new function

  • change axios cache to https://www.npmjs.com/package/axios-cache-interceptor?activeTab=readme
  • make error message clear
    • when user not found (400 status response) image

RedHeadphone avatar Aug 10 '24 13:08 RedHeadphone