Skip to content
2 changes: 1 addition & 1 deletion src/app/api/generate/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { generateWithWaveSpeed } from "./providers/wavespeed";
// Re-export for backward compatibility (test file imports from route)
export const clearFalInputMappingCache = _clearFalInputMappingCache;

export const maxDuration = 300; // 5 minute timeout (Vercel hobby plan limit)
export const maxDuration = 900; // 15 minute timeout (Vercel Pro limit)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Keep this route at the repository’s 5-minute timeout.

Changing maxDuration to 900 breaks the file-specific contract for src/app/api/generate/route.ts. If video jobs need 15 minutes, they should move to a separate endpoint or workflow instead of changing the shared generate route’s timeout here.

As per coding guidelines, "**/api/generate/route.ts: Image generation API route must have a 5 minute timeout in src/app/api/generate."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/api/generate/route.ts` at line 25, The maxDuration constant in
src/app/api/generate/route.ts was increased to 900, violating the repository
rule that the shared generate route must use a 5-minute timeout; change the
exported constant maxDuration back to 300 (5 minutes) so the generate route
honors the file-specific contract, and if longer video jobs are required, move
them to a separate endpoint or workflow instead of modifying maxDuration here.

export const dynamic = 'force-dynamic'; // Ensure this route is always dynamic


Expand Down
7 changes: 7 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"functions": {
"src/app/api/generate/route.ts": {
"maxDuration": 900
}
Comment on lines +3 to +5
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

vercel.json functions maxDuration Next.js App Router configuration

💡 Result:

To set Vercel Function timeouts for Next.js App Router route handlers (app/api/**/route.ts), use the functions map in vercel.json and match the built function entrypoints with a glob pattern. Vercel applies the config to every function file that matches the pattern (including App Router Route Handlers). [1] [2]

Example (app/ at repo root)

{
  "functions": {
    "app/api/**/route.ts": { "maxDuration": 60 }
  }
}

This works for App Router APIs like app/api/hello/route.ts. [3]

If you use a src/ directory

Prefix the pattern with src/:

{
  "functions": {
    "src/app/api/**/route.ts": { "maxDuration": 60 }
  }
}

Vercel notes the /src/ prefix is required for detection when your project uses a src directory. [1]

Alternative (per route/page/segment, in code)

Next.js App Router also supports:

export const maxDuration = 60;

directly from a Route Handler / Page / Layout via Route Segment Config. [4]

Notes

  • maxDuration is in seconds and must be within your plan’s allowed maximum. [2]

Sources
[1] https://vercel.com/docs/functions/configuring-functions/duration
[2] https://vercel.com/docs/project-configuration/vercel-json
[3] vercel/community#4391
[4] https://nextjs.org/docs/13/app/api-reference/file-conventions/route-segment-config


🏁 Script executed:

git log --oneline -n 20 | head -20

Repository: shrimbly/node-banana

Length of output: 130


Update maxDuration to 300 seconds (5 minutes) and use glob pattern for function path.

The configuration has two issues:

  1. maxDuration is set to 900 seconds (15 minutes) but the requirement specifies 5 minutes (300 seconds).
  2. Per Vercel documentation for Next.js App Router in src/ projects, use the glob pattern src/app/api/**/route.ts instead of an exact file path.
Suggested fix
{
  "functions": {
    "src/app/api/**/route.ts": {
      "maxDuration": 300
    }
  }
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@vercel.json` around lines 3 - 5, Replace the specific function entry
"src/app/api/generate/route.ts" and its maxDuration value of 900 with a globbed
function path and 300-second limit: update the functions key to use
"src/app/api/**/route.ts" and set maxDuration to 300; locate the JSON entry
referencing "src/app/api/generate/route.ts" and change the key to the glob
pattern and the "maxDuration" property to 300 to comply with Vercel Next.js App
Router requirements.

}
}
Comment on lines +1 to +7
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check the documented timeout requirements in CLAUDE.md

# Search for timeout-related documentation
rg -n -C3 'timeout|maxDuration|generate' CLAUDE.md

Repository: shrimbly/node-banana

Length of output: 3509


🏁 Script executed:

cat -n vercel.json

Repository: shrimbly/node-banana

Length of output: 207


Configure API route timeouts per project documentation.

The vercel.json configuration has two issues:

  1. The src/app/api/generate/route.ts timeout is set to 900 seconds (15 minutes), but CLAUDE.md specifies it should be 5 minutes (300 seconds). If the use case has changed to require 15 minutes, update CLAUDE.md to document the new requirement.

  2. The src/app/api/llm/route.ts route is missing from the configuration. Per CLAUDE.md, it requires a 1-minute timeout. Add:

    "src/app/api/llm/route.ts": {
      "maxDuration": 60
    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@vercel.json` around lines 1 - 7, The vercel.json timeouts are inconsistent
with CLAUDE.md: change the maxDuration for generate/route.ts from 900 to 300
seconds (or, if 15 minutes is intentional, update CLAUDE.md to reflect 900s),
and add a new entry for llm/route.ts with "maxDuration": 60 to set the 1-minute
timeout; update the vercel.json functions object accordingly so it contains both
generate/route.ts with the corrected value and llm/route.ts with 60.