Next.js Discord

Discord Forum

Increase max duration

Answered
Masai Lion posted this in #help-forum
Open in Discord
Masai LionOP
Hey, I am facing with 504 timeouts and I want to increase the max duration of my script, but I don't know where exactly to update it.

I've attached few images for a better understanding of the problem. I truly can't identify where should I implement the maxDuration constant.
Answered by Masai Lion
@Jboncz I managed to fix it by increasing the maxDuration timeout to my server components:

app/page.tsx
app/[locale]/page.tsx
app/[locale]/layout.tsx


also with the following vercel.json

{
  "functions": {
    "app/api/**/*": {
      "maxDuration": 90
    }
  }
}
View full answer

11 Replies

Whats timing out? Are you hitting a route handler? a server action? What is it your doing?
Masai LionOP
@Jboncz I managed to fix it by increasing the maxDuration timeout to my server components:

app/page.tsx
app/[locale]/page.tsx
app/[locale]/layout.tsx


also with the following vercel.json

{
  "functions": {
    "app/api/**/*": {
      "maxDuration": 90
    }
  }
}
Answer
Thatll do it! 🙂
Masai LionOP
@Jboncz can you help me with a question? I do have here the Pro plan, and would I be charged more if I upgrade the function CPU for my project?
I dont honestly know. I self host everything.
Masai LionOP
oof
Never deployed to vercel
Masai LionOP
you're a brave person
eh, I work in an enterprise environment I have people backing my infrastructure so I dont have to worry about the resources. I need more Storage/Ram/CPU power, I tell them I need it and they give it lol
for the most part
Masai LionOP
in my current employer, I do also have a DevOps team to take care of it, but since this project is for my new company, I need to do it by hand xD