vercel/next.js · error

Client Max Body Size must be larger than 0 bytes

Error message

Client Max Body Size must be larger than 0 bytes

What it means

After accepting the type, config.ts:1073-1075 checks that the parsed/numeric value is not NaN and is at least 1 byte. A value of 0, a negative number, or an unparseable string that `bytes.parse` turns into NaN triggers this. This enforces a sane floor before the value is stored as a normalized number.

Source

Thrown at packages/next/src/server/config.ts:1074

  // Normalize & validate experimental.proxyClientMaxBodySize
  if (typeof result.experimental?.proxyClientMaxBodySize !== 'undefined') {
    const proxyClientMaxBodySize = result.experimental.proxyClientMaxBodySize
    let normalizedValue: number

    if (typeof proxyClientMaxBodySize === 'string') {
      const bytes =
        require('next/dist/compiled/bytes') as typeof import('next/dist/compiled/bytes')
      normalizedValue = bytes.parse(proxyClientMaxBodySize)
    } else if (typeof proxyClientMaxBodySize === 'number') {
      normalizedValue = proxyClientMaxBodySize
    } else {
      throw new Error(
        'Client Max Body Size must be a valid number (bytes) or filesize format string (e.g., "5mb")'
      )
    }

    if (isNaN(normalizedValue) || normalizedValue < 1) {
      throw new Error('Client Max Body Size must be larger than 0 bytes')
    }

    // Store the normalized value as a number
    result.experimental.proxyClientMaxBodySize = normalizedValue
  }

  warnOptionHasBeenMovedOutOfExperimental(
    result,
    'transpilePackages',
    'transpilePackages',
    configFileName,
    silent
  )
  warnOptionHasBeenMovedOutOfExperimental(
    result,
    'skipMiddlewareUrlNormalize',
    'skipMiddlewareUrlNormalize',
    configFileName,

View on GitHub (pinned to 0ae8c72462)

Solutions

  1. Set a positive number of bytes or a recognized filesize string (`'5mb'`, `'1gb'`).
  2. To effectively disable the cap, omit the option or use a large value.
  3. Pre-validate strings with `require('bytes').parse(v)` and confirm it returns a finite positive number.

Example fix

// before
module.exports = { experimental: { proxyClientMaxBodySize: 0 } }
// after
module.exports = { experimental: { proxyClientMaxBodySize: '5mb' } }
Defensive patterns

Strategy: validation

Validate before calling

const bytes = require('bytes');
const raw = config.experimental?.proxyClientMaxBodySize;
if (raw !== undefined) {
  const n = typeof raw === 'number' ? raw : bytes.parse(raw);
  if (isNaN(n) || n < 1) throw new Error('proxyClientMaxBodySize must be > 0 bytes');
}

Type guard

function isPositiveBytes(v: unknown): boolean {
  const n = typeof v === 'number' ? v : typeof v === 'string' ? require('bytes').parse(v) : NaN;
  return typeof n === 'number' && !isNaN(n) && n >= 1;
}

Prevention

When it happens

Trigger: Setting `proxyClientMaxBodySize: 0`, `proxyClientMaxBodySize: -1`, or `proxyClientMaxBodySize: 'not-a-size'` (bytes.parse returns NaN).

Common situations: Using 0 intending 'no limit' (use a very large number or omit instead). Env var defaulting to '0'. Mis-typed unit that bytes.parse cannot read.

Related errors


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