vercel/next.js · error
--routes cannot be empty
Error message
--routes cannot be empty
What it means
Thrown by parseCli when the --routes flag, after splitting on commas, trimming, and filtering empty strings, yields zero routes. The client tracer must trace at least one route, so an empty set is rejected immediately rather than producing an empty trace.
Source
Thrown at bench/render-pipeline/client-trace.ts:165
}
const args = new Map<string, string>()
for (const rawArg of rawArgs) {
if (!rawArg.startsWith('--')) continue
const eq = rawArg.indexOf('=')
if (eq === -1) {
args.set(rawArg.slice(2), 'true')
} else {
args.set(rawArg.slice(2, eq), rawArg.slice(eq + 1))
}
}
const routes = (args.get('routes') ?? '/,/dashboard,/docs,/blog,/tailwind')
.split(',')
.map((route) => route.trim())
.filter(Boolean)
if (routes.length === 0) {
throw new Error('--routes cannot be empty')
}
for (const route of routes) {
if (!route.startsWith('/')) {
throw new Error(`Each route must start with '/': ${route}`)
}
}
const samples = parseNumberArg(args, 'samples', 3)
if (samples < 1) {
throw new Error(`--samples must be at least 1, got ${samples}`)
}
// CDP rejects rates below 1 (1 = no throttling).
const cpuThrottle = parseNumberArg(args, 'cpu-throttle', 4)
if (cpuThrottle < 1) {
throw new Error(`--cpu-throttle must be at least 1, got ${cpuThrottle}`)
}
const timestamp = new Date().toISOString().replace(/[:.]/g, '-')View on GitHub (pinned to 0ae8c72462)
Solutions
- Omit --routes entirely to use the defaults (/,/dashboard,/docs,/blog,/tailwind).
- Provide at least one route path, e.g. --routes=/.
- If building the value from a variable, guard for empty before passing the flag.
Example fix
// before --routes= // after (omit for defaults) // no --routes flag
Defensive patterns
Strategy: validation
Validate before calling
const routesArg = process.env.BENCH_ROUTES ?? ''
const routes = routesArg
? routesArg.split(',').map(r => r.trim()).filter(Boolean)
: undefined // let CLI default
if (routesArg && routes.length === 0) {
throw new Error('--routes resolved to empty; omit the flag for defaults')
} Type guard
null
Try / catch
null
Prevention
- Omit --routes to accept the documented defaults.
- When building --routes from a variable, skip the flag entirely if the value is empty.
When it happens
Trigger: Passing --routes= (empty), --routes=,,, (only commas), or --routes=" " (only whitespace).
Common situations: An environment variable expanding to empty is interpolated into --routes; a script that builds the routes string produced nothing; user cleared the list intending defaults but passed the empty flag.
Related errors
- Invalid --top value: ${topRaw}
- Invalid numeric value for --${key}: ${value}
- --routes cannot be empty
- Each route must start with '/': ${route}
- Invalid --scenario value: ${scenarioRaw}. Use e2e|minimal-se
AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06).
Data as JSON: /api/errors/25ea834d4dc70946.
Report an issue: GitHub.