Next.js Discord

Discord Forum

Does API function timeout if it’s triggered by multiple cron jobs?

Answered
American Bobtail posted this in #help-forum
Open in Discord
American BobtailOP
I need to send a newsletter to 20k subscribers. Resend doesn’t yet support bulk email sending, so I want to build my own using Resend, Vercel Cron and Next.js API route.

I am not certain though, will a serverless function timeout if I keep triggering it via cron every second for like half an hour?
Answered by linesofcode
But it will be a brand new lambda function execution
View full answer

12 Replies

Hey @American Bobtail your function will time out in 10 or 60 seconds, depending on your plan
American BobtailOP
Yes, but what if I call the same function multiple times, in few secs difference? Wouldn’t it try using the same warm lambda and timeout as a result?
It will (most likely, but not 100% guaranteed) use the same warm lambda container.
But it will be a brand new lambda function execution
Answer
And will have the same rules as other lambdas. 10 or 60 seconds of runtime
The only thing that may be shared between the lambdas (assuming the warm container was reused) is any variables in global scope
American BobtailOP
Yeah, need to test that out. Want to try avoid using 3rd party tools if possible for now for background jobs.
I totally understand
Vercel doesn’t make this scenario easy
You need some sort of locking mechanism
If you’re planning on processing the emails concurrently
American BobtailOP
Yeah… it’s nice they added cron jobs. But queueing system would be perfect. So I don’t need to trigger stupid amount of crons without knowing how long should I keep triggering.