ServerActions MaxDuration Config [504 Timeout]
Answered
Western Scrub-Jay posted this in #help-forum
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. ðŸ™ðŸ½
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
3 Replies
Have you tried putting this to the page where this form render?
export const maxDuration = 100Western Scrub-JayOP
Thank you, it works.
I added it on the main page.
I added it on the main page.