#504 error on PRO plan vercel Next.js APP directory

26 messages · Page 1 of 1 (latest)

fresh sandBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

keen barn
#

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.

proud flicker
#

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
loud slateBOT
#

@queen stag

Crossposting and reposting the same question across different channels is not allowed

Crossposting (posting a question in a channel and send the question link to another channel) and reposting (posting the same question in several channels) are not allowed in this server. See the server rules in #welcome message for more information.

proud flicker
#

-timeout @queen stag 1h repeated reposting in the help forum

rapid umbraBOT
#

⏱ Timed out spacer2231 for 1 hour

queen stag
queen stag
#

anyone?

queen stag
#

anyone?

queen stag
#

anyone?

inner mulch
queen stag
#

?

queen stag
#

?

proud flicker
#

don't bump more than once a day

#

i don't want to warn you more than this

queen stag
#

?

queen stag
#

?\

worn meteor
#

😢 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.