Initial function invocation times out, subsequent invocations complete
Unanswered
Spectacled bear posted this in #help-forum
Spectacled bearOP
Hi there, I'm a beginner dev working on a Next.js 14 project that's deployed to Vercel. In my project users can submit a form to call a route handler that calls the OpenAI API to generate an image using DALL-E based on the form. This process takes between 15-35 seconds typically.
Naturally, being on the Hobby Vercel plan initially, the function timed out after 10 seconds. So I upgraded to Pro, which has a timeout limit of 300 seconds. I redeployed and the image generation started working.
But now I have a weird problem. The initial function invocation times out around 15 seconds, giving me a 504 Gateway Timeout response. But any invocations after that complete, giving me a 200 OK response.
I'm not sure what to do about this, other than breaking out the API call and maybe using an Edge Function? But I haven't done that before so I wanted to see if maybe there's another solution.
Thanks for reading, and helping!
Naturally, being on the Hobby Vercel plan initially, the function timed out after 10 seconds. So I upgraded to Pro, which has a timeout limit of 300 seconds. I redeployed and the image generation started working.
But now I have a weird problem. The initial function invocation times out around 15 seconds, giving me a 504 Gateway Timeout response. But any invocations after that complete, giving me a 200 OK response.
I'm not sure what to do about this, other than breaking out the API call and maybe using an Edge Function? But I haven't done that before so I wanted to see if maybe there's another solution.
Thanks for reading, and helping!