vercel/next.js · error
Server Actions Size Limit must be a valid number or filesize
Error message
Server Actions Size Limit must be a valid number or filesize format larger than 1MB: https://nextjs.org/docs/app/api-reference/next-config-js/serverActions#bodysizelimit
What it means
`experimental.serverActions.bodySizeLimit` must parse to a positive number of bytes. The check at config.ts:950-968 uses `bytes.parse` for strings and accepts a number directly; it throws when the result is null, NaN, or less than 1 (byte). The message text mentions 1MB but the actual code floor is 1 byte, so any non-parseable or non-positive value triggers it.
Source
Thrown at packages/next/src/server/config.ts:965
result.output = 'standalone'
}
if (
typeof result.experimental?.serverActions?.bodySizeLimit !== 'undefined'
) {
const bytes =
require('next/dist/compiled/bytes') as typeof import('next/dist/compiled/bytes')
const bodySizeLimit = result.experimental.serverActions.bodySizeLimit
let value: number | null
if (typeof bodySizeLimit === 'number') {
value = bodySizeLimit
} else {
value = bytes.parse(bodySizeLimit)
}
if (value === null || isNaN(value) || value < 1) {
throw new Error(
'Server Actions Size Limit must be a valid number or filesize format larger than 1MB: https://nextjs.org/docs/app/api-reference/next-config-js/serverActions#bodysizelimit'
)
}
}
// Throw if both Middleware and Proxy config are set.
if (
userConfig.experimental?.proxyClientMaxBodySize !== undefined &&
userConfig.experimental?.middlewareClientMaxBodySize !== undefined
) {
throw new Error(
'Config options `experimental.proxyClientMaxBodySize` and `experimental.middlewareClientMaxBodySize` cannot be set at the same time. Please use `experimental.proxyClientMaxBodySize` instead.'
)
}
if (
userConfig.experimental?.proxyPrefetch !== undefined &&
userConfig.experimental?.middlewarePrefetch !== undefined
) {View on GitHub (pinned to 0ae8c72462)
Solutions
- Use a valid filesize string supported by the bytes library: `'1mb'`, `'4mb'`, `'2gb'`, or a positive number of bytes.
- If you want the default, remove `bodySizeLimit` (default is 1MB).
- Verify with `require('bytes').parse(yourValue)` in a scratch script before committing.
Example fix
// before
module.exports = { experimental: { serverActions: { bodySizeLimit: 'abc' } } }
// after
module.exports = { experimental: { serverActions: { bodySizeLimit: '4mb' } } } Defensive patterns
Strategy: validation
Validate before calling
const bytes = require('bytes');
const v = config.experimental?.serverActions?.bodySizeLimit;
if (v !== undefined) {
const n = typeof v === 'number' ? v : bytes.parse(v);
if (n === null || isNaN(n) || n < 1) throw new Error('invalid bodySizeLimit: ' + v);
} Type guard
function isValidBodySizeLimit(v: unknown): boolean {
if (typeof v === 'number') return v >= 1;
if (typeof v === 'string') { const n = require('bytes').parse(v); return typeof n === 'number' && !isNaN(n) && n >= 1; }
return false;
} Prevention
- Pre-validate bodySizeLimit with bytes.parse before committing.
- Use canonical unit strings like '1mb', '4mb'.
When it happens
Trigger: Setting `experimental: { serverActions: { bodySizeLimit: 'abc' } }` (unparseable string), `bodySizeLimit: 0`, `bodySizeLimit: -5`, or `bodySizeLimit: ''`.
Common situations: Typos in unit strings (`'1mb'` is valid, `'1 m b'` is not). Copying a config that used a bare number expecting MB but writing 0 or negative. Using a value type bytes.parse does not recognize.
Related errors
- Client Max Body Size must be a valid number (bytes) or files
- Client Max Body Size must be larger than 0 bytes
- Invalid "${name}" provided, expected a finite number of seco
- Specified distDir is not a string, found type "${typeof valu
- Specified basePath has to start with a /, found "${result.ba
AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06).
Data as JSON: /api/errors/e901cb7176ddc3e2.
Report an issue: GitHub.