vercel/next.js · error · Error
Invalid "${name}" provided, expected a finite number of seco
Error message
Invalid "${name}" provided, expected a finite number of seconds or Infinity, received ${value} What it means
Thrown by normalizeInfiniteDuration() when a duration config value is neither a finite number nor Infinity. The function accepts undefined or finite numbers as-is and maps Infinity to INFINITE_CACHE; anything else (NaN, a string, -Infinity, an object) is rejected. It validates expireTime and experimental.staleTimes.dynamic/static.
Source
Thrown at packages/next/src/server/config.ts:128
}
}
return [warnings, fatalErrors]
}
// Infinity means "never", but turns into null when serialized as JSON (e.g.
// for build workers or the prerender manifest), unlike INFINITE_CACHE.
function normalizeInfiniteDuration(
value: number | undefined,
name: string
): number | undefined {
if (value === undefined || Number.isFinite(value)) {
return value
}
if (value === Infinity) {
return INFINITE_CACHE
}
throw new Error(
`Invalid "${name}" provided, expected a finite number of seconds or Infinity, received ${value}`
)
}
export function warnOptionHasBeenDeprecated(
config: NextConfig,
nestedPropertyKey: string,
reason: string,
silent: boolean
): boolean {
let hasWarned = false
if (!silent) {
let current = config
let found = true
const nestedPropertyKeys = nestedPropertyKey.split('.')
for (const key of nestedPropertyKeys) {
if ((current as any)[key] !== undefined) {
current = (current as any)[key]View on GitHub (pinned to 0ae8c72462)
Solutions
- Provide a finite number of seconds (e.g. 60) or Infinity for 'never'.
- Ensure the value is a number type, not a string -- remove quotes.
- If computing the value, guard against NaN/undefined before assignment.
- Avoid -Infinity; use 0 for immediate expiry or Infinity for never.
Example fix
// before
// module.exports = { expireTime: '3600', experimental: { staleTimes: { dynamic: -Infinity } } }
// after
// module.exports = { expireTime: 3600, experimental: { staleTimes: { dynamic: 60 } } } Defensive patterns
Strategy: type-guard
Validate before calling
// Validate duration config before assigning.
function asDuration(v: unknown): number | undefined {
if (v === undefined) return undefined
if (v === Infinity) return Infinity
if (typeof v === 'number' && Number.isFinite(v)) return v
throw new Error('duration must be a finite number or Infinity')
} Type guard
function isValidDuration(v: unknown): v is number | undefined {
return v === undefined || v === Infinity || (typeof v === 'number' && Number.isFinite(v))
} Prevention
- Use numeric literals (not strings) for duration configs.
- Guard computed values against NaN before assignment.
- Use Infinity for 'never', not -Infinity or a huge string.
- Type your config to prevent non-number values.
When it happens
Trigger: next.config.js sets expireTime or experimental.staleTimes.dynamic/static to a non-finite, non-Infinity value (e.g. a string like '60', NaN, -Infinity). During config normalization (config.ts:1375-1386), normalizeInfiniteDuration throws.
Common situations: Passing a string instead of a number to a duration config; computing a value that yields NaN (e.g. undefined arithmetic); using -Infinity by mistake; copy-pasting a config with quoted numbers.
Related errors
- Specified distDir is not a string, found type "${typeof valu
- Invalid urlPath provided to revalidate(), must be a path e.g
- Server Actions Size Limit must be a valid number or filesize
- Client Max Body Size must be a valid number (bytes) or files
- Client Max Body Size must be larger than 0 bytes
AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06).
Data as JSON: /api/errors/0b32e40707b08b77.
Report an issue: GitHub.