vercel/next.js · error
Invalid numeric value for --${key}: ${value}
Error message
Invalid numeric value for --${key}: ${value} What it means
Thrown by parseNumberArg (benchmark.ts:107) when a CLI numeric option's value fails Number.isFinite after Number() coercion. Used for --warmup-requests, --serial-requests, --load-requests, --load-concurrency, --timeout-ms, and --port. The check rejects NaN (non-numeric), Infinity, and -Infinity, but does NOT reject negatives or zero — those flow through and may cause downstream issues.
Source
Thrown at bench/render-pipeline/benchmark.ts:107
mode: StreamMode
routeResults: FullRoutePhaseResult[]
routeDocuments: RouteDocumentInfo[]
}
function parseBoolean(value: string): boolean {
return value === '1' || value === 'true' || value === 'yes'
}
function parseNumberArg(
args: Map<string, string>,
key: string,
fallback: number
): number {
const value = args.get(key)
if (value === undefined) return fallback
const parsed = Number(value)
if (!Number.isFinite(parsed)) {
throw new Error(`Invalid numeric value for --${key}: ${value}`)
}
return parsed
}
function parseRoutes(rawRoutes: string | undefined): string[] {
if (!rawRoutes) {
return [
'/',
'/attributes',
'/tailwind',
'/dashboard',
'/docs',
'/blog',
'/streaming/light',
'/streaming/medium',
'/streaming/heavy',
'/streaming/chunkstorm',
'/streaming/wide',View on GitHub (pinned to 0ae8c72462)
Solutions
- Provide a finite integer: --port=3199, --load-requests=1200.
- Never use bare numeric flags; always --key=value.
- Note this guard does not catch negatives/zero — sanity-check ranges that matter (port, concurrency) in your wrapper.
- If scripting the invocation, validate values are finite positive integers before passing them.
Example fix
// before // pnpm bench:render-pipeline --port=3l99 --load-requests= // after // pnpm bench:render-pipeline --port=3199 --load-requests=1200
Defensive patterns
Strategy: validation
Validate before calling
function parseFiniteInt(value: string | undefined, fallback: number, min = -Infinity): number {
if (value === undefined) return fallback
const n = Number(value)
if (!Number.isFinite(n)) throw new Error(`expected a number, got ${value}`)
if (!Number.isInteger(n) || n < min) throw new Error(`expected int >= ${min}, got ${value}`)
return n
} Type guard
function isFiniteNumericString(s: string): boolean {
const n = Number(s)
return s.trim() !== '' && Number.isFinite(n)
} Try / catch
try {
const port = parseNumberArg(args, 'port', 3199)
} catch (err) {
console.error((err as Error).message, '\nPass numeric flags as --key=integer')
process.exit(2)
} Prevention
- Always use --key=value for numeric flags, never bare flags (bare -> 'true' -> NaN).
- Add range validation in wrappers for values that have semantic bounds (port 1-65535, concurrency >= 1).
- Note parseNumberArg rejects NaN/Infinity but NOT negatives or zero — validate those yourself.
- Sanity-check templated env-var-derived values before forwarding.
When it happens
Trigger: Passing any numeric flag a non-numeric or infinite value, e.g. --port=abc, --load-requests=1e999 (Infinity), --warmup-requests= (empty -> NaN), or a bare flag where the parser default-sets value to 'true' -> Number('true') = NaN.
Common situations: A bare flag without =N (--port instead of --port=3199) is parsed as 'true' and becomes NaN here; forwarding an unset env var as the value; typos like --port=3l99.
Related errors
- Invalid --top value: ${topRaw}
- --routes cannot be empty
- Each route must start with '/': ${route}
- Invalid --scenario value: ${scenarioRaw}. Use e2e|minimal-se
- Invalid --stream-mode value: ${streamModeRaw}. Use node
AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06).
Data as JSON: /api/errors/1471f81529645981.
Report an issue: GitHub.