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

  1. Provide a finite integer: --port=3199, --load-requests=1200.
  2. Never use bare numeric flags; always --key=value.
  3. Note this guard does not catch negatives/zero — sanity-check ranges that matter (port, concurrency) in your wrapper.
  4. 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

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


AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06). Data as JSON: /api/errors/1471f81529645981. Report an issue: GitHub.