vercel/next.js · error · Error
Invalid `cacheLife()` option. Either pass a profile name or
Error message
Invalid `cacheLife()` option. Either pass a profile name or object.
What it means
Type guard in cacheLife() for the non-string branch: the argument is neither a string profile name nor a plain object — it is null, an array, or another non-object type. The function only accepts a profile name or a cacheLife options object, so anything else is rejected before any profile resolution happens.
Source
Thrown at packages/next/src/server/use-cache/cache-life.ts:88
`Did you mean "${profile.trim()}" without the spaces?`
)
}
throw new Error(
`Unknown \`cacheLife()\` profile "${profile}" is not configured in next.config.js\n` +
'module.exports = {\n' +
' cacheLife: {\n' +
` "${profile}": ...\n` +
' }\n' +
'}'
)
}
profile = configuredProfile
} else if (
typeof profile !== 'object' ||
profile === null ||
Array.isArray(profile)
) {
throw new Error(
'Invalid `cacheLife()` option. Either pass a profile name or object.'
)
} else {
profile = validateAndNormalizeCacheLifeProfile(profile, { kind: 'inline' })
}
if (profile.revalidate !== undefined) {
// Track the explicit revalidate time.
if (
workUnitStore.explicitRevalidate === undefined ||
workUnitStore.explicitRevalidate > profile.revalidate
) {
workUnitStore.explicitRevalidate = profile.revalidate
}
}
if (profile.expire !== undefined) {
// Track the explicit expire time.
if (View on GitHub (pinned to 258b1c1bc0)
Solutions
- Pass a profile name string or a config object to cacheLife().
Defensive patterns
Strategy: type-guard
When it happens
Trigger: cacheLife() receives an argument that is neither a profile name nor an object.
Common situations: Passing a number, boolean, or null to cacheLife().
AI-assisted analysis of vercel/next.js@258b1c1bc0 (2026-08-19).
Data as JSON: /api/errors/d1d63d5c853880c0.
Report an issue: GitHub.