vercel/next.js · error

Command failed: ${command} ${args.join(' ')} (exit ${code})

Error message

Command failed: ${command} ${args.join(' ')} (exit ${code})

What it means

Thrown by runCommand after a spawned child process (node, next build, a fixture generator) exits with a non-zero code. The error echoes the full command, args, and exit code so the underlying failure is visible. This wraps build/setup steps the tracer depends on.

Source

Thrown at bench/render-pipeline/client-trace.ts:216

        `bench/render-pipeline/artifacts/${timestamp}-client`
    ),
    jsonOut: args.get('json-out'),
  }
}

async function runCommand(
  command: string,
  args: string[],
  cwd: string
): Promise<void> {
  const child = spawn(command, args, {
    cwd,
    env: { ...process.env, NEXT_TELEMETRY_DISABLED: '1' },
    stdio: 'inherit',
  })
  const [code] = (await once(child, 'exit')) as [number | null]
  if (code !== 0) {
    throw new Error(
      `Command failed: ${command} ${args.join(' ')} (exit ${code})`
    )
  }
}

async function waitForServerReady(
  url: string,
  timeoutMs: number,
  serverDied?: () => boolean
): Promise<void> {
  const start = performance.now()
  while (performance.now() - start < timeoutMs) {
    // Without this check, a server that dies on startup (e.g. EADDRINUSE
    // against a stale server on the same port) is indistinguishable from
    // a slow one — worse, a 200 from whatever else owns the port would
    // pass, and the run would silently measure the wrong server.
    if (serverDied?.()) {
      throw new Error(

View on GitHub (pinned to 0ae8c72462)

Solutions

  1. Re-run the exact failing command (shown in the message) manually to see the full stderr.
  2. Fix the underlying compile/build error in the fixture or generator.
  3. If the build is already done and current, drop --build=true to skip rebuilding.
  4. Confirm the node and next binaries are on PATH and the right version.

Example fix

// before: build fails due to fixture error
node packages/next/dist/bin/next build  # shows the real error

// after: fix the error, then trace
pnpm bench:render-pipeline:client --build=false
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

try {
  await runCommand('node', [NEXT_BIN, 'build'], appDir)
} catch (e) {
  // The message includes the failing command; run it manually for full output
  console.error('Build step failed — re-run manually:', (e as Error).message)
  throw e
}

Prevention

When it happens

Trigger: next build fails (compile error, missing dependency); a fixture graph generator script errors; the node binary path is wrong; a build step is interrupted.

Common situations: Running client-trace with --build=true against a fixture with a syntax error; the generator script (generate-client-graph.mjs) throws; node version mismatch.

Related errors


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