Vercel function times out on a long report export, should I move it to a queue or a different host?
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:
Cite
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.Task timed out after 300.00 secondsI looked at raising
maxDurationbut 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:
- Raise the duration limit and keep the code as is.
- Return immediately, do the work in the background, and email a download link.
- 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?
Write something first.
Give people something to work with: at least 30 words on what happened and what you tried.
That is too long. Keep it under 6,000 characters.
Write the question as the title, 15 to 140 characters, no links.
Pick a category.
Add a name (2 to 40 characters, no links).
That email address does not look right.
That was quick. Read the thread, then try again.
The form expired. Reload the page and post again.
Something went wrong with the form. Reload and try again.
Please complete the check and post again.
Limit reached for now. Try again later.
This thread is closed to new replies.
This thread no longer accepts replies.
Something went wrong with the form. Reload and try again.
Post a reply or question first (name and email), then this browser can vote, edit and accept answers.
You cannot vote on your own post.
Only the author (within 30 days) or the forum team can do that.
That email already has an account. Use your sign-in link instead.
New accounts are paused for the moment. Try again later.
That was already posted.