1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Vercel Runtime Timeout Error: Task timed out after 10 seconds

Posted at

はじめに

大したエラーではないのですがエラー文で検索してもパッと出てこなかったのでAIでも見つけやすくするのも兼ねて記事にします。

問題

VercelにホスティングしていたNext.jsアプリでレスポンスに時間がかかるAPI(Route Hundlers)を実行した際に以下のエラーが出る。

Vercel Runtime Timeout Error: Task timed out after 10 seconds

原因と解決策

VercelではNext.jsのRoute HundlersやServer Actionsはサーバーレス関数として扱われるのですが、デフォルトだと処理の最大実行時間が10秒になっています。

元のRoute Hundlersの記述に以下の一行を追加することで最大実行時間を指定できます。(Server Actionsの場合はPage単位で指定します)

export const maxDuration = 60; // これを指定
 
export function GET(request: Request) {
  return new Response('Vercel', {
    status: 200,
  });
}

上記例だとAPIごとに指定していますが、GUIからプロジェクト全体の最大実行時間を指定もできるみたいです。

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?