I have an app where after the user signs in with 3rd party application, the user's followings are retrieved from that service. For each of the followings, I get more data from another API and store this overall information in my database.
In my test account with 70 followings, this process takes ~20 minutes (including timeouts due to API rate limits).
const addFollowings = async followings => {
const followingsData = []
for (const following of followings) {
const { id, name } = following
const personInfo = new PersonInfo(name)
await personInfo.init()
const number = ...
// ...
followingsData.push({ name, id, number, ... })
console.log('new following:', name)
}
await insertFollowingsIntoDB(followingsData)
}
This works fine in development. But I have just deployed the app on Vercel, and when it comes to executing this function, firstly only a few followings are console-logged, then the function gets stuck: nothing is logged. Only when I refresh the page (which triggers /api/auth/session serverless function to get called), a few more are logged.
I guess this is because Vercel 10s limits execution for functions. Please advise how I should handle this. Thanks in advance.