Next.js Discord

Discord Forum

504 error on PRO plan vercel Next.js APP directory

Unanswered
Oak apple gall wasp posted this in #help-forum
Open in Discord
Original message was deleted.

24 Replies

You have to go to the vercel logs and check which function is timing out.
Post the function code here and a picture of the logs where the function times out
Also don't make several posts. Just bump this one by putting a message in here.
text content from the other post (i'll now delete that post because it's a duplicate. do not repost the same question)

---

Hey everyone, do you have any ideas about why Vercel is returning a 504 error? I'm on the pro plan, and my serverless functions are configured to run for a maximum of 5 minutes. Typically, my functions take about 2-3 minutes to execute.

In the logs, I can see that the serverless function is returning a 200 status code, and it's executing correctly. However, when I access it through the browser, after about 1 minute, it returns a 504 error.

Everything works fine locally. What could be the issue?"


app/api/generators/article/refine/route.ts
import { type NextRequest } from "next/server";

import { type GetArticle } from "@/types/types";
import GeneratorsAPI from "@/lib/GeneratorsApi/GeneratorsAPI";

export const maxDuration = 300;

export async function POST(request: NextRequest) {
  const payload = (await request.json()) as GetArticle;

  return await GeneratorsAPI.getInstance().getRefinedArticle(payload);
}


lib/GeneratorsAPI

async getRefinedArticle(payload: GetArticle) {
    try {
      this.validatePayloadWith(this.articleValidator, payload);

      const response = await axios.post(this.REFINED, payload, {
        headers: this.headers,
        timeout: 300000,
      });

      const data = response as ArticleAPIReturnType;
      return NextResponse.json({ data: data.data.data }, { status: 200 });
    } catch (err) {
      const error = handleError(err, "getRefinedArticle");

      return NextResponse.json(
        { message: error.message },
        { status: error.errorCode },
      );
    }
  }


This is data from VERCEL LOGS for /refine route


Status Code 200
Execution duration/limit 1m 45.76s / 250s
function /api/generators/article/refine
-timeout @Oak apple gall wasp 1h repeated reposting in the help forum
Oak apple gall wasp
Oak apple gall wasp
Oak apple gall wasp
Oak apple gall wasp
anyone?
Oak apple gall wasp
anyone?
Oak apple gall wasp
anyone?
please only bump once per day... this will allow for other questions to be answered and your can still get back to the top again (one per hour isn't even going to give much advantage anyway)
["Rule 8: Bumping posts in ⁠#help-forum is allowed if you still need help. Please, do not do it more than once a day"](https://canary.discord.com/channels/752553802359505017/752553802359505020/1108132432609284187)
Oak apple gall wasp
?
Oak apple gall wasp
?
don't bump more than once a day
i don't want to warn you more than this
Oak apple gall wasp
?
Oak apple gall wasp
?\
Leafcutting bee
😢 it seems this issues has been goign on for a while.

This maxDuration / 504 timeout issue has pretty much crippled our live product, and we are getting no answer from support (we have a pro plan)

We may have to switch over to cloud run on GCP. I really dont want to, but no idea what else we can do.
Oak apple gall wasp
its fixed, I created issue on that and they fixcedi t