nextjs - 💡(How to fix) Fix Next.js 16: Serialization timing issue with unstable_cache causes "Objects are not valid as a React child" error [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#85342Fetched 2026-04-08 02:16:20
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Author
Timeline (top)
closed ×2labeled ×2commented ×1issue_type_added ×1

Error Message

Error: Objects are not valid as a React child (found: object with keys {response, handler, parentObject, key, map, path, isDebug}).

Root Cause

  • unstable_cache returns the original unserialized object on first invocation before caching
  • Subsequent requests work fine (cache hits return serialized data)
  • This behavior exists in both Next.js 15 and 16
  • However: Next.js 16 + React 19 changed RSC serialization, so these properties now cause errors when passed to Payload's Lexical Client Component

Fix Action

Workaround

const page = await getPageById()
const safePage = JSON.parse(JSON.stringify(page))
return <RichText data={safePage.content} />

Code Example

Error: Objects are not valid as a React child (found: object with keys {response, handler, parentObject, key, map, path, isDebug}).

---

const page = await getPageById()
const safePage = JSON.parse(JSON.stringify(page))
return <RichText data={safePage.content} />
RAW_BUFFERClick to expand / collapse

Issue

When using unstable_cache with Payload CMS Lexical rich text in Next.js 16, non-enumerable __internal properties survive the first cache invocation, causing React rendering errors.

Error

Error: Objects are not valid as a React child (found: object with keys {response, handler, parentObject, key, map, path, isDebug}).

Root Cause

  • unstable_cache returns the original unserialized object on first invocation before caching
  • Subsequent requests work fine (cache hits return serialized data)
  • This behavior exists in both Next.js 15 and 16
  • However: Next.js 16 + React 19 changed RSC serialization, so these properties now cause errors when passed to Payload's Lexical Client Component

Workaround

const page = await getPageById()
const safePage = JSON.parse(JSON.stringify(page))
return <RichText data={safePage.content} />

Versions

  • Next.js: 16.0.0
  • Payload CMS: 3.61.0
  • React: 19.x

extent analysis

TL;DR

To fix the React rendering errors caused by non-enumerable __internal properties when using unstable_cache with Payload CMS Lexical rich text in Next.js 16, apply a workaround that serializes the data before passing it to the Lexical Client Component.

Guidance

  • Identify the specific component or function where the unstable_cache is being used and verify that the data being passed to the Lexical Client Component is the cause of the error.
  • Apply the provided workaround by serializing the data using JSON.parse(JSON.stringify(data)) before passing it to the component.
  • Test the workaround to ensure it resolves the React rendering errors.
  • Consider exploring alternative caching solutions that do not return unserialized objects on the first invocation.

Example

const page = await getPageById()
const safePage = JSON.parse(JSON.stringify(page))
return <RichText data={safePage.content} />

Notes

This workaround may have performance implications due to the additional serialization step, and it may not be suitable for all use cases. Further investigation into alternative caching solutions or updates to the unstable_cache implementation may be necessary.

Recommendation

Apply the workaround, as it provides a temporary solution to the React rendering errors caused by the non-enumerable __internal properties. This workaround allows for continued use of the unstable_cache with Payload CMS Lexical rich text in Next.js 16 until a more permanent solution is available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING