What is the limit for data passed from a server component to a client component in RSC?
Unanswered
Iridescent shark posted this in #help-forum
Iridescent sharkOP
After upgrading to NextJS 15 (App router) some of my <Suspense> boundaries (wrapping RSCs) were stuck showing the
After debugging it seems to happen when passing a certain treshold of too much data from a server component to a client component. See the attached screen recording (#1). When it's working correctly the RSC data is available in the DOM tree, but when passing a treshold the data is no longer to be found in the DOM tree and the UI is stuck showing
I think there are more twists to the story; I think I was able to make the data appear by making a change in the source-code and triggering a HMR/rebuild. Perhaps also by clicking around and then coming back to the component in question.
Also, when I tried to reproduce the issue it was difficult because I didn't seem to hit a limitation when using arrays of objects (see attachment #2).
Perhaps me using something "unconventional" like a
Interestingly me changing the map during testing from
First and foremost I'm looking for a solution; reducing the amount of the data might be one option, but that would be a last resort for me as it's, to my knowledge, impossible to know the treshold during development.
loading.ts
. I suspect it has something to do with Next's serialization/deserialization of data passed from server components to client components. It might not be directly related to upgrading to NextJS, but rather that I had to disable next-superjson-plugin
due to https://github.com/vercel/next.js/issues/72019. Therefore it seems to be a problem/limitation in Next.js.After debugging it seems to happen when passing a certain treshold of too much data from a server component to a client component. See the attached screen recording (#1). When it's working correctly the RSC data is available in the DOM tree, but when passing a treshold the data is no longer to be found in the DOM tree and the UI is stuck showing
loading.ts
. The issue seemed to happen when I created a production build as well.I think there are more twists to the story; I think I was able to make the data appear by making a change in the source-code and triggering a HMR/rebuild. Perhaps also by clicking around and then coming back to the component in question.
Also, when I tried to reproduce the issue it was difficult because I didn't seem to hit a limitation when using arrays of objects (see attachment #2).
Perhaps me using something "unconventional" like a
Map
is part of the issue?Interestingly me changing the map during testing from
{myObject}.lineup
(this is a Map) to Array.from({myObject}.lineup.entries())
solved the issue. Although I wasn't able to reproduce the issue by adding a small Map. Perhaps the Map must be of a substantial size like the one I use (the .entries()
version gives about 2877 chars)?First and foremost I'm looking for a solution; reducing the amount of the data might be one option, but that would be a last resort for me as it's, to my knowledge, impossible to know the treshold during development.