Long running fire and forget style jobs on NextJS + Vercel
Unanswered
Dutch Smoushond posted this in #help-forum
Dutch SmoushondOP
Hi! I have a server action that inserts a job into a database and then immediately returns a job id. The client then polls the state of the job through another server action. I'm having problems kicking off a serverless job to perform the actual job work though. My current plan was to create an api route that I can call from the creating server action. However, the create server action cannot await the result of the fetch that invokes the work route, so it is not guaranteed to ever actually run; this is because I'm guessing the serverless instance could get shutdown at any time after the create server action completes.
I was really hoping to use vercel's serverless functions and not have to use another provider for lambda operations. Is there a pattern for how to achieve this?
Perhaps a next API to start an API route?
If this is not possible, what solutions would you recommend that work nicely with a NextJS app?
I was really hoping to use vercel's serverless functions and not have to use another provider for lambda operations. Is there a pattern for how to achieve this?
Perhaps a next API to start an API route?
If this is not possible, what solutions would you recommend that work nicely with a NextJS app?