{"record":{"id":"e39622fbb6530d1a","repo":"vercel/next.js","slug":"maxpostponedstatesize-must-be-a-valid-number-byte","errorCode":null,"errorMessage":"maxPostponedStateSize must be a valid number (bytes) or filesize format string (e.g., \"5mb\")","messagePattern":"maxPostponedStateSize must be a valid number \\(bytes\\) or filesize format string \\(e\\.g\\., \"5mb\"\\)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/lib/postponed-request-body.ts","lineNumber":25,"sourceCode":"const INVALID_MAX_POSTPONED_STATE_SIZE_ERROR_MESSAGE =\n  'maxPostponedStateSize must be a valid number (bytes) or filesize format string (e.g., \"5mb\")'\n\nexport type PostponedRequestBodyChunk = Buffer | Uint8Array | string\n\nexport function getMaxPostponedStateSize(\n  configuredMaxPostponedStateSize: SizeLimit | undefined\n): {\n  maxPostponedStateSize: SizeLimit\n  maxPostponedStateSizeBytes: number\n} {\n  const maxPostponedStateSize =\n    configuredMaxPostponedStateSize ?? DEFAULT_MAX_POSTPONED_STATE_SIZE\n  const maxPostponedStateSizeBytes = parseMaxPostponedStateSize(\n    configuredMaxPostponedStateSize\n  )\n\n  if (maxPostponedStateSizeBytes === undefined) {\n    throw new Error(INVALID_MAX_POSTPONED_STATE_SIZE_ERROR_MESSAGE)\n  }\n\n  return { maxPostponedStateSize, maxPostponedStateSizeBytes }\n}\n\nexport function getPostponedStateExceededErrorMessage(\n  maxPostponedStateSize: SizeLimit\n): string {\n  return (\n    `Postponed state exceeded ${maxPostponedStateSize} limit. ` +\n    `To configure the limit, see: https://nextjs.org/docs/app/api-reference/config/next-config-js/max-postponed-state-size`\n  )\n}\n\nfunction toBuffer(chunk: PostponedRequestBodyChunk): Buffer {\n  return Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)\n}\n","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/lib/postponed-request-body.ts#L7-L43","documentation":"Thrown by getMaxPostponedStateSize when the experimental.experimental.maxPostponedStateSize config value cannot be parsed into bytes by the bytes library (parseSizeLimit returns undefined). The value must be a positive number (bytes) or a filesize string like '5mb'.","triggerScenarios":"next.config.js sets experimental.maxPostponedStateSize to an unparseable value such as 'abc', an empty string, 0, or a negative number. The bytes parser returns null/NaN/<1 and parseMaxPostponedStateSize returns undefined.","commonSituations":"Typo in the size string, using a unit bytes doesn't recognize, or passing a non-numeric value. Encountered at server boot when PPR/postponed state handling initializes.","solutions":["Set experimental.maxPostponedStateSize to a valid filesize string like '100mb' or a positive byte number.","Remove the option entirely to use the default (100 MB).","Verify the unit is supported by the bytes library (b, kb, mb, gb, tb)."],"exampleFix":"// before\nmodule.exports = {\n  experimental: { maxPostponedStateSize: 'lots' }, // unparseable\n}\n\n// after\nmodule.exports = {\n  experimental: { maxPostponedStateSize: '100mb' },\n}","handlingStrategy":"validation","validationCode":"const bytes = require('bytes')\nfunction validateMaxPostponedSize(v: unknown): void {\n  const n = bytes.parse(v)\n  if (n === null || isNaN(n) || n < 1) throw new Error('Invalid maxPostponedStateSize')\n}","typeGuard":"function isValidSizeLimit(v: unknown): v is string | number {\n  if (typeof v === 'number') return v >= 1\n  if (typeof v === 'string') {\n    const n = require('bytes').parse(v)\n    return n !== null && !isNaN(n) && n >= 1\n  }\n  return false\n}","tryCatchPattern":"null","preventionTips":["Use recognized units (b, kb, mb, gb) for size strings.","Leave maxPostponedStateSize unset to accept the 100 MB default.","Validate config in a pre-start script."],"tags":["config","ppr","size-limit","experimental"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}