{"record":{"id":"9be654d4ccb892da","repo":"vercel/next.js","slug":"error-serializing-path-returned-from-metho-9be654","errorCode":null,"errorMessage":"Error serializing `${path}` returned from `${method}` in \"${page}\".\nReason: `${type}` cannot be serialized as JSON. Please only return JSON serializable data types.","messagePattern":"Error serializing `(.+?)` returned from `(.+?)` in \"(.+?)\"\\.\nReason: `(.+?)` cannot be serialized as JSON\\. Please only return JSON serializable data types\\.","errorType":"exception","errorClass":"SerializableError","httpStatus":null,"severity":"error","filePath":"packages/next/src/lib/is-serializable-props.ts","lineNumber":128,"sourceCode":"        value.every((nestedValue, index) => {\n          const newRefs = new Map(refs)\n          return isSerializable(newRefs, nestedValue, `${path}[${index}]`)\n        })\n      ) {\n        return true\n      }\n\n      throw new SerializableError(\n        page,\n        method,\n        path,\n        `invariant: Unknown error encountered in Array.`\n      )\n    }\n\n    // None of these can be expressed as JSON:\n    // const type: \"bigint\" | \"symbol\" | \"object\" | \"function\"\n    throw new SerializableError(\n      page,\n      method,\n      path,\n      '`' +\n        type +\n        '`' +\n        (type === 'object'\n          ? ` (\"${Object.prototype.toString.call(value)}\")`\n          : '') +\n        ' cannot be serialized as JSON. Please only return JSON serializable data types.'\n    )\n  }\n\n  return isSerializable(new Map(), input, '')\n}\n","sourceCodeStart":110,"sourceCodeEnd":144,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/lib/is-serializable-props.ts#L110-L144","documentation":"Thrown by isSerializableProps() when a value's typeof is one of bigint, symbol, function, or a non-plain object type that is neither null nor an Array. None of these can be expressed in JSON. The message includes the type (and for objects, the Object.prototype.toString tag) so the developer can locate the offending value.","triggerScenarios":"A leaf or nested value in props is a bigint (e.g. BigInt ID), a Symbol, a function/component reference, or a non-plain object like a Date, Map, Set, RegExp, Error, ArrayBuffer, or class instance that is not caught by isPlainObject.","commonSituations":"Returning a Date object instead of an ISO string; bigint IDs from a database; passing a function/component reference in props; Map/Set/Buffer from Node APIs; class instances from domain models. Different from [113] which fires at the root; this fires on nested non-serializable values.","solutions":["Convert Dates to ISO strings (date.toISOString()).","Convert bigint to string (id.toString()) or number if safe.","Replace Map/Set with plain objects/arrays; convert Buffer to base64 string.","Strip or serialize class instances via .toJSON()/.toObject() before returning."],"exampleFix":"// before\nexport async function getStaticProps() {\n  const item = await getItem(id)\n  return { props: { item: { id: item.id, createdAt: item.createdAt } } }\n  // createdAt is a Date, id is bigint -> error\n}\n// after\nexport async function getStaticProps() {\n  const item = await getItem(id)\n  return {\n    props: {\n      item: { id: String(item.id), createdAt: item.createdAt.toISOString() },\n    },\n  }\n}","handlingStrategy":"validation","validationCode":"function toSerializable(v: unknown): unknown {\n  if (v instanceof Date) return v.toISOString()\n  if (typeof v === 'bigint') return v.toString()\n  if (v instanceof Map) return Object.fromEntries(v)\n  if (v instanceof Set) return [...v]\n  if (v && typeof v === 'object' && typeof (v as any).toJSON === 'function') return (v as any).toJSON()\n  if (Array.isArray(v)) return v.map(toSerializable)\n  if (v && typeof v === 'object') return Object.fromEntries(Object.entries(v).map(([k,n])=>[k,toSerializable(n)]))\n  return v\n}\n// return { props: toSerializable(props) }","typeGuard":"function isJsonPrimitive(v: unknown): boolean {\n  return v === null || ['boolean','number','string'].includes(typeof v)\n}","tryCatchPattern":null,"preventionTips":["Convert Date → ISO string, bigint → string, Map/Set → plain equivalents before returning.","Define toJSON on domain models so serialization is automatic.","Add a serialize linter/test for getStaticProps return values.","Avoid passing functions/components/symbols in props."],"tags":["serialization","getstaticprops","getserversideprops","build","data-fetching"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}