Files
Hendrik LiebauandGitHub 8de4b60049 Make 'use cache' fill timeout configurable (#93070)
Applications can now override the `'use cache'` fill timeout through a
new `experimental.useCacheTimeout` config (in seconds, matching the
`staticPageGenerationTimeout` / `cacheLife` configs), which lets them
raise the timeout for slower dev-time backends or lower it for faster
feedback while iterating. Without a value set, the timeout defaults to
90% of `staticPageGenerationTimeout`, landing at 54s against the 60s
default build timeout — slightly higher than the previous hard-coded
50s.

During static and runtime prerendering, the effective timeout is clamped
to `0.9 × staticPageGenerationTimeout` so the cache-fill error surfaces
before the build worker kills the page. In dev mode, the configured
value is used as-is since there's no equivalent build-worker kill. The
defaulting and clamp are centralized in a single
`getUseCacheFillTimeoutMs` helper in `use-cache-wrapper.ts`, replacing
the previous module-level `USE_CACHE_FILL_TIMEOUT_MS` constant.

The new value is threaded through `RenderOpts` and `WorkStore`.
Proxy/middleware and the edge route-module wrapper construct a WorkStore
but never fill `'use cache'` entries, so they pass `0` sentinels with a
comment — if anything ever reads these values, the cache will time out
immediately and surface the bug loudly. We'll revisit this if we ever
add `'use cache'` support to Proxy.

A new `use-cache-configured-timeout` fixture exercises the clamp by
setting `staticPageGenerationTimeout: 10` and flipping `useCacheTimeout`
between `15` (in dev, via `process.env.__NEXT_DEV_SERVER`) and `60` (in
build). Two pages, one sleeping 11s (between the 9s clamp and the 15s
dev timeout) and one sleeping 17s (above the dev timeout), let us assert
that the dev value is applied without clamping and that the build clamps
both pages. The existing `use-cache-hanging` fixture now sets
`useCacheTimeout: 10` so tests don't race the browser's `page.goto`
ceiling, and the explicit 180s test timeouts there have been dropped in
favor of the Jest default.
2026-04-21 22:45:36 +02:00

14 lines
326 B
JavaScript

/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
cacheComponents: true,
experimental: {
// Lower the `'use cache'` fill timeout so tests don't race the browser's
// page.goto ceiling (default ~60s) after the 54s default + compile time.
useCacheTimeout: 10,
},
}
module.exports = nextConfig