# Vercel function times out on a long report export, should I move it to a queue or a different host?

Source: https://gitshowcase.com/forum/discuss/vercel-function-times-out-on-a-long-report-export-should-i-move/
Site: GitShowcase Forum, category Hosting, Edge and Deploys
Published: 2026-11-29. Updated: 2026-11-30. Replies: 2.

## Question by Ilse K., 2026-11-29

One of my small SaaS apps lets customers export a full year of activity as a CSV. The export endpoint is a Next.js route handler on Vercel that queries Postgres, builds the file in memory and returns it. For small accounts it is instant. For a couple of bigger customers it gets cut off and they see a 504 in the browser. Runtime logs show:

```text
Task timed out after 300.00 seconds
```

I looked at raising `maxDuration` but I do not love the idea of a request that sits open for many minutes, and a user closing the tab would waste the work anyway.

Options I am weighing:

1. Raise the duration limit and keep the code as is.
2. Return immediately, do the work in the background, and email a download link.
3. Move this one endpoint to a long running server somewhere else (a small VM or container).

I am cost conscious and the exports are rare, so I do not want to run a server all month for them. What would you do, and what is the simplest queue setup if that is the answer?

## Reply 1 by Anand R., 2026-11-29

Option 2. A request that holds a connection for minutes will fail for reasons that have nothing to do with your platform: mobile networks, proxies, browser tabs. Return a job id right away, do the work separately, let the client poll or send an email.

## Reply 2 by Teodor M., 2026-11-30

You do not need a queue product to start. A `jobs` table in the Postgres you already have, plus a worker that does `SELECT ... FOR UPDATE SKIP LOCKED LIMIT 1`, covers a handful of exports a day. Add a real queue when you outgrow that.

---
Cite as: GitShowcase Forum, "Vercel function times out on a long report export, should I move it to a queue or a different host?", https://gitshowcase.com/forum/discuss/vercel-function-times-out-on-a-long-report-export-should-i-move/, accessed 2026-11-30.
