Skip to content
Latchkey

Vercel "Build exceeded maximum duration" - Fix Slow Builds in CI

Vercel cancelled the build because it ran past the maximum allowed duration. Either the build genuinely got slower, or a step hung - a watch task that never exits, or a stalled network fetch.

What this error means

The build is killed after a fixed window with The build exceeded the maximum allowed duration. A build that hung on a stuck step often passes on retry; a build that is simply too slow needs real optimization.

Vercel build log
Error: The build exceeded the maximum allowed duration. Your build was
automatically canceled.

Common causes

A hung or stuck build step

A dev/watch command left in the build, a process waiting on input, or a stalled network call can hang the build until it is force-cancelled. These are transient and often clear on retry.

Genuinely too-slow build

Large dependency installs with no cache, heavy asset processing, or building everything in a big monorepo can legitimately exceed the limit.

How to fix it

Ensure the build is non-interactive and exits

  1. Make sure the Build Command is the production build (vite build), not a watch/dev server.
  2. Run installs and tools in CI/non-interactive mode so nothing waits on input.
  3. If a step hangs on a flaky fetch, retry the deploy - a hung fetch usually clears.

Speed the build up

Cut the work the build does: cache dependencies, build only what changed, and skip non-essential steps.

vercel.json
{
  "buildCommand": "turbo run build --filter=web",
  "installCommand": "npm ci"
}

How to prevent it

  • Keep the Build Command to the production build only; never a watch task.
  • Cache dependencies and use affected-only builds in monorepos.
  • Move heavy one-off processing out of the per-deploy build path.

Frequently asked questions

What causes ""exceeded maximum duration""?
A dev/watch command left in the build, a process waiting on input, or a stalled network call can hang the build until it is force-cancelled. These are transient and often clear on retry.
How do I fix "exceeded maximum duration"?
Ensure the build is non-interactive and exits
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card