I'm working on a project where I'm using Vercel to handle API routes for enqueuing jobs using BullMQ and Redis. Everything works perfectly in development, but I'm running into an issue in production. The api's make call to openAi so the response takes over a minute each time.
Here's my setup:
- Vercel: I'm using Vercel to deploy my Next.js API routes. The routes include one for starting a job (
/api/startArticleGeneration) and another for checking the status of a job. - BullMQ & Redis: I'm using BullMQ to manage job queues, with Redis as the backend. The job creation and status checking work fine, but the actual job processing doesn't seem to happen in production after deploying to Vercel.
The problem:
When I trigger the job creation API, it responds with a 202 Accepted status, but the job doesn't seem to be processed after that. The same setup works perfectly in my local development environment, where the jobs are processed as expected.
I suspect the issue is related to Vercel's serverless environment, where long-running processes aren't supported but I am not entirely sure. Is there some way to handle this with Vercel or should I redeploy elsewhere.