Next.js Discord

Discord Forum

Vercel.json API timeout

Answered
Atlantic horse mackerel posted this in #help-forum
Open in Discord
Avatar
Atlantic horse mackerelOP
I'm keep getting this error for some invocations on my api due a timeout
This Serverless Function has timed out.

Your connection is working correctly.

Vercel is working correctly.

504: GATEWAY_TIMEOUT
Code: FUNCTION_INVOCATION_TIMEOUT
ID: cle1::9vjlj-1686611576039-053e9e54f266


So I wrote this in my vercel.json
{
  "functions": {
    "/pages/api/*.js": { "maxDuration": 60 }
  }
}
But I'm getting this error
Error: The function path "/pages/api/*.js" is invalid. The path must be relative to your project root and therefore cannot start with a slash.
invalid_function_source: The function path "/pages/api/*.js" is invalid. The path must be relative to your project root and therefore cannot start with a slash.


Does anyone know how to fix it?
Answered by Rafael Almeida
or maybe "pages/api/**/*.js"
View full answer

18 Replies

Avatar
if your intention is to increase the default timeout limit, keep in mind this can only be done by changing your account plan
Avatar
Atlantic horse mackerelOP
I did actually. I have the pro vercel version.
Avatar
it should be increased automatically, did you upgraded recently?
Avatar
Atlantic horse mackerelOP
Yeah I did it today.
Avatar
I would wait a bit, but if it takes too long you can create a post in https://github.com/orgs/vercel/discussions
Avatar
Atlantic horse mackerelOP
I just put a wallet address with a large amount of borrows.
Thank you bro. Appreciate you answering so fast.
I'll def make an issue
But do you know how to set this up properly
{
  "functions": {
    "/pages/api/*.js": { "maxDuration": 60 }
  }
}
Bec I'm getting an error for it as well in my vercel.json
Avatar
just make sure this specific operation is not also taking longer than 60s 😅
for the config error you probably want "pages/api/*.js"
Avatar
or maybe "pages/api/**/*.js"
Answer
Avatar
Atlantic horse mackerelOP
This worked
And it fixed my issue.
Do you work at Vercel?
Avatar
nope, I just like helping on my free time