{"record":{"id":"eb9c14b2e4721582","repo":"vercel/next.js","slug":"the-router-state-header-was-sent-but-could-not-be","errorCode":null,"errorMessage":"The router state header was sent but could not be parsed.","messagePattern":"The router state header was sent but could not be parsed\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/app-render/parse-and-validate-flight-router-state.tsx","lineNumber":40,"sourceCode":"      'Multiple router state headers were sent. This is not allowed.'\n    )\n  }\n\n  // We limit the size of the router state header to ~40kb. This is to prevent\n  // a malicious user from sending a very large header and slowing down the\n  // resolving of the router state.\n  // This is around 2,000 nested or parallel route segment states:\n  // '{\"children\":[\"\",{}]}'.length === 20.\n  if (stateHeader.length > 20 * 2000) {\n    throw new Error('The router state header was too large.')\n  }\n\n  try {\n    const state = JSON.parse(decodeURIComponent(stateHeader))\n    assert(state, flightRouterStateSchema)\n    return state\n  } catch {\n    throw new Error('The router state header was sent but could not be parsed.')\n  }\n}\n","sourceCodeStart":22,"sourceCodeEnd":43,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/server/app-render/parse-and-validate-flight-router-state.tsx#L22-L43","documentation":"parseAndValidateFlightRouterState wraps JSON.parse of the decoded header plus a superstruct schema assert in a try block; this error is thrown when the header cannot be decoded/parsed or the state does not match the FlightRouterState schema, i.e. the client sent a malformed router state.","triggerScenarios":"Thrown at packages/next/src/server/app-render/parse-and-validate-flight-router-state.tsx:40 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The `next-router-state-tree` header contained invalid JSON; ensure nothing tampers with it in proxies or custom servers.","Upgrade Next.js so client and server versions match."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0eb377541648e63402a47b38fee00a8d0ce8f8f1","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}