Next.js Discord

Discord Forum

getServerSideProps loading very slow (above 7sec)

Unanswered
davdixyz posted this in #help-forum
Open in Discord
My plan is basic, im using supabase with getServerSideProps to get the current user session, and if the session is null redirect the user to the homepage but the performance is very bad. The first load takes up to 5-10 secs and i don't really know how to solve this.
Attached an image for how my code looks.

22 Replies

i saw a similar question a few days ago. it seemed like cold start time issue. but i wonder if it is really or not.
one thing different is in ur case you use db so does it use connection pool? im not familiar with supabase
Something similar yes, if anyone tries to navigate the https://xyz.com/test route the first load takes up to 5-10 secs, after that if you tries to navigate the second time it works fine (under 1sec)
But no one wants to wait literally 7 seconds to this
in general, connections pool takes much time so reducing number of pool size works.
even if im not calling any request to the database the first load slow.
does it happen a simple hello world program with a few libs in package.json?
for me with the libs i need this still takes 7 sec to load
import { GetServerSideProps, NextPage } from "next";
import * as React from "react";

const TestPage: NextPage = () => {
  return <div>Hello World</div>;
};
export const getServerSideProps: GetServerSideProps = async () => {
  return {
    props: {
      id: 1,
    },
  };
};
export default TestPage;
oh
any one help us plz.
which region do u use?
@davdixyz go to the log in vercel, there should be a "cold boot duration" there, what is the number in your case?
@joulev
@davdixyz <@484037068239142956>
cold boot only 247ms, it's your code that is slow... is there a getInitialProps in your page/app?
Nope, im only using getStaticProps and getServerSideProps
then i honestly don't know what's wrong either, it shouldn't take that long...
is there some kind of middleware?
@joulev is there some kind of middleware?
tried with a newly created nextjs project and still loads slow for first time with no API call in getServerSideProps
Spotted Owl
I am having a similar issue I think. I am not using Vercel I am using Docker and k8s via NextJS standalone configuration.

For whatever reason some of the NextJS serverside calls take forever and the GraphQL calls I am doing on the server are way faster. Here is what my waterfall looks like.
All of the /_next/data/UfJkDFiYwvt6fs3UbBoPE/channels/vtg2-network.json?channel=vtg2-net "_next/data" calls are taking way longer and holding up the browser event loop
It appears it is pre-fetching the content for each of the pages, there are links to all those pages on the page being loaded but then you look in the network request and there is a query id but then there is no data for the query id... its like its pre-fetching but not actually getting the data.
I noticed that this issue is only happens on vercel for me. Tested on localhost and the first load is around 600ms.