Too many Static Pages to render in getStaticPaths() causing vercel build fail Error...
Answered
Labh posted this in #help-forum
LabhOP
I'm trying to render static pages for my dynamic routes
I'm using firestore to get my data for page
I know the data json I'm fetching for each page is large which I can reduce further, so if I static render like 300 pages it works and all pages are rendered..
So I've 464 docs in firestore collection if I increase the limit more than 300 vercel deploy fails
But it didn't tell me what error was
What the cause for this? Is the vercel limits the build or there are total size limit?
I'm using firestore to get my data for page
export async function getStaticPaths() {
const q = query(collection(db, "musicians"), limit(300));
const querySnapshot = await getDocs(q);
const paths = querySnapshot.docs.map((doc) => ({
params: { id: doc.id },
}));
return {
paths,
fallback: "blocking",
};
}
// Fetch data for a single doc
export async function getStaticProps(context) {
const id = context.params?.id;
const docRef = doc(db, "musicians", id);
const docSnap = await getDoc(docRef);
if (!docSnap.exists()) {
return {
notFound: true,
};
}I know the data json I'm fetching for each page is large which I can reduce further, so if I static render like 300 pages it works and all pages are rendered..
So I've 464 docs in firestore collection if I increase the limit more than 300 vercel deploy fails
But it didn't tell me what error was
What the cause for this? Is the vercel limits the build or there are total size limit?
10 Replies
LabhOP
UP
@Labh I'm trying to render static pages for my dynamic routes
I'm using firestore to get my data for page
`export async function getStaticPaths() {
const q = query(collection(db, "musicians"), limit(300));
const querySnapshot = await getDocs(q);
const paths = querySnapshot.docs.map((doc) => ({
params: { id: doc.id },
}));
return {
paths,
fallback: "blocking",
};
}
// Fetch data for a single doc
export async function getStaticProps(context) {
const id = context.params?.id;
const docRef = doc(db, "musicians", id);
const docSnap = await getDoc(docRef);
if (!docSnap.exists()) {
return {
notFound: true,
};
}
`
I know the data json I'm fetching for each page is large which I can reduce further, so if I static render like 300 pages it works and all pages are rendered..
So I've 464 docs in firestore collection if I increase the limit more than 300 vercel deploy fails
But it didn't tell me what error was
What the cause for this? Is the vercel limits the build or there are total size limit?
10000 lines of logs seem excessive. What’s causing all these 10k lines? I have a feeling this 10k number is what causes the build to abort. 300 pages seem normal, I’ve built apps with 1.7k static pages before no problems
LabhOP
All logs are json data for each page,
I forgot to get the specific field that I need to show on page directly fetched all json data
it's about 3000 line json data per file...
I forgot to get the specific field that I need to show on page directly fetched all json data
it's about 3000 line json data per file...
Also logs is not the problem I guess cause the 300 one that build successfully also have 10k lines
@Labh All logs are json data for each page,
I forgot to get the specific field that I need to show on page directly fetched all json data
it's about 3000 line json data per file...
Still, try not logging for a particular deployment
Answer
And see if it works
@joulev Still, try not logging for a particular deployment
LabhOP
How to do that?
@Labh How to do that?
By just removing the console.log calls? Why do those logs show up?
@joulev By just removing the console.log calls? Why do those logs show up?
LabhOP
OoO I forgot that...
I can see the error now, one doc after 300th had invalid data was causing error, that was not showing due to these 10k logs😂 ...
I can see the error now, one doc after 300th had invalid data was causing error, that was not showing due to these 10k logs😂 ...
Thanks