-
Hello y'all, I have a getServerSideProps method fetching a quite big object (12mb). But when I return this object the request becomes extremly slow even without building the component with this data. The query of that object isn't the issue here. As you can see (I added the results in the code) the query itself is quite ok if I dont pass the object as prop. export const getServerSideProps: GetServerSideProps = async function (params) {
const res = await fetch(`${SERVER_DOMAIN}/api/list`);
const data = await res.json();
console.log(memorySizeOf(data)); // 12mb
// this takes 25 to 40 sec to load with next dev
// this takes 1.4 sec to load with next build && next start
return { props: { data } };
// this takes 1.55 sec to load with next dev
// this takes 1.11 sec to load with next build && next start
return { props: { ok: "ok" } };
};
export default function Home() {
return <div>ok</div>;
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
|
Beta Was this translation helpful? Give feedback.
-
Our development mode has a strict object shape verification process that takes some time to process the 12MB, so I'd say this is behaving as expected. It's not a bug, and is pointing out you should simplify your return structure. |
Beta Was this translation helpful? Give feedback.
getServerSideProps
andgetStaticProps
are meant for kilobytes of data, not megabytes. Everything you return from this function is downloaded by your user on initial page visit.Our development mode has a strict object shape verification process that takes some time to process the 12MB, so I'd say this is behaving as expected. It's not a bug, and is pointing out you should simplify your return structure.