Runtime limits
What you need to know
A runtime limit is a bound on execution time, memory, payload size or another resource. Separate application-controlled budgets from deployment-provider limits.
By the end, you can: identify platform time and resource limits; design bounded tests.
Declare a platform duration hint
// app/api/health/route.ts; Cache Components offexport const maxDuration=5;export function GET(){return Response.json({ready:true});}Expected behavior: A successful request should return ready true. Five seconds is a configured hint for supporting platforms, not an observed timeout.
How it works
A route segment maxDuration export can communicate an execution duration setting to supported deployment platforms; it is not a portable JavaScript timeout or proof of enforcement. The provider may cap it or interpret it according to its plan. The application still needs bounded downstream calls, input sizes and retry budgets. AbortSignal can request cancellation from APIs that honor it; it does not forcibly stop arbitrary computation or undo committed writes. Choose a deadline shorter than the outer request budget and reserve time for cleanup. Use a fixed test clock or manually controlled abort event for deterministic unit cases. A production test should observe actual timeouts and cleanup on the selected platform, without deliberately exhausting shared resources.
A pure remaining-budget calculation
function remaining(start:number,now:number,budget:number){ return Math.max(0,budget-Math.max(0,now-start));}console.log(remaining(100,160,80),remaining(100,190,80));Expected behavior: 20 0, with all times expressed in the same units. This models a deadline; it does not cancel a request.
Common mistake
Never treat maxDuration as proof a downstream request stopped. A retry after an ambiguous mutation result can repeat a write; use a bounded, idempotency-aware policy.
Practice and verification
Design a local test with one success, one deadline exhausted before the call, one downstream abort and one cleanup assertion. Keep actual hosting limits marked unverified.
Scope: Proposed Next.js 16.x / React 19, Cache Components disabled unless noted. Framework, browser and component examples are staged; local standalone tests are reported separately. Exact dependency patches and platform contracts pending.