Timeout loop

I created a small Telegram bot using one of my Vercel functions, without using any libraries other than node-fetch@2.7.0. The bot uses fetch to get data from another API. Sometimes, when that API doesn’t respond, the function times out and returns a 504 status to Telegram. This causes Telegram to call my webhook URL again with the same data, creating a loop.

Not only does this happen, but it also causes my other functions to start timing out, even though they don’t have any issues. I still haven’t found an easy way to fix this :pensive_face:

Hi @nxrix, an easy fix for this would be to implement a timer for such calls. You can use Promise.race (docs) to timeout the fetch request if it doesn’t resolve in x seconds. Then, handle this correctly in your serverless function so it doesn’t timeout, returning a 504.

Your other functions should be unrelated to this error. Can you share logs or something to show that they are getting affected by this error in another function?