Next.js Discord

Discord Forum

ServerActions MaxDuration Config [504 Timeout]

Answered
Western Scrub-Jay posted this in #help-forum
Open in Discord
Western Scrub-JayOP
My question is about the scrapeWeb server action. Is there a config to increase the maxDuration of the scrapeWeb server action as mine keeps timing out at 15s on the pro plan.

I tried adding the path app/actions/.ts in my vercel.json but nothing is working.

I also tried adding the pages path to the vercel.json file as server actions inherit the runtime of the pages / layout component they are used in, but it still does not work.

'use client'

import { useFormState } from 'react-dom'
import { scrapeWeb } from '@/app/actions'

const initialState = {
message: '',
}

export function ScrapeForm() {
const [state, formAction] = useFormState(scrapeWeb, initialState)

return (
<form action={formAction}>
<input type="text" name="url" required />
{/
... */}
<p aria-live="polite" className="sr-only">
{state?.message}
</p>
<button>Scrape</button>
</form>
)
}

Your assistance would be highly appreciated. 🙏🏽
Answered by Ray
maxDuration for server action should set it on the route segment where the action execute
View full answer

3 Replies