next.js MaxDuration 5 minutes不工作|Serverless|专业计划|504错误|VERCEL

cbjzeqam  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(100)

我正在使用Next.js@latest和应用目录
我的应用程序托管在Vercel
你知道为什么Vercel会返回504错误吗?我使用的是**专业计划,**我的无服务器功能配置为最多运行5分钟。通常,我的函数需要大约2-3分钟来执行。
在日志中,我可以看到无服务器函数返回了一个200状态代码,并且它正在正确执行。然而,**当我通过浏览器或 Postman 访问它时,大约1分钟后,它返回504错误。
当地一切都很好。会是什么问题呢?
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 },
      );
    }
  }

这是来自VERCEL LOGS的/refine路线数据

Status Code: 200
Execution duration/limit: 1m 45.76s / 250s
function: /api/generators/article/refine
Environment: production
h43kikqp

h43kikqp1#

他们在Vercel那边有问题,已经解决了。

相关问题