Issue with Static generation and ISR
See original GitHub issueWhat version of Next.js are you using?
11.0.0
What version of Node.js are you using?
14.16.1
What browser are you using?
Microsoft Edge
What operating system are you using?
Windows
How are you deploying your application?
next start
Describe the Bug
I am observing inconsistent behavior with static generation and ISR (getStaticPaths & getStaticProps). My requirement is pull a list of reports available from the database for a certain Type and Category. For the example code given below, the code runs perfectly on my local machine (Node Version 14.16.1 on Windows). However on AWS server (Node Version 14.18.0 Ubuntu Linux), the build script only picks up 3-4 static paths and then while running, it says failed to getStaticProps - which possibly should be some exception that I am not getting on my local machine somehow. I also tried to run the database access code separately on my AWS server however it resulted the correct output.
Expected Behavior
The code should reflect same behavior whether Ubuntu or Windows. Also the fallback: true from getStaticPaths doesn’t seems to be working. On Ubuntu, setting fallback: true results in getStaticProps error and fallback:false results in 404 error. I tried getStaticPaths both ways - pulling those from Db (as commented code) and hardcoding. But no difference.
To Reproduce
export async function getStaticPaths() { /* const reportMaster = await daos.getReportMaster(); const categories = await reportMaster.getAllCategories(); const paths = await categories.map((data) => ({ params: { category: encodeURI(
${data.category}), reportType:
${data.reportType}` },
}));
return { paths, fallback: true }
*/
return {
paths: [{
params: { category: ‘Fixed Income And Currency Market’, reportType: ‘Research’ },
params: { category: ‘Credit Market’, reportType: ‘Research’ },
params: { category: ‘Credit Research’, reportType: ‘Research’ },
params: { category: ‘RBI Policy’, reportType: ‘Research’ },
params: { category: ‘Equity Market’, reportType: ‘Research’ },
params: { category: ‘Union Budget’, reportType: ‘Research’ },
params: { category: ‘Blogs’, reportType: ‘Knowledge’ },
params: { category: ‘Support’, reportType: ‘Knowledge’ },
params: { category: ‘Liquidity Cheat Sheet’, reportType: ‘MarketData’ },
params: { category: ‘Primary Corporate Bond Market’, reportType: ‘MarketData’ },
params: { category: ‘Corporate Bond and Money Market Traded Data’, reportType: ‘MarketData’ },
params: { category: ‘RBI Operations’, reportType: ‘MarketData’ },
params: { category: ‘Deposit and Credit Data’, reportType: ‘MarketData’ },
params: { category: ‘Forex Data’, reportType: ‘MarketData’ },
params: { category: ‘FII investment’, reportType: ‘MarketData’ },
}],
fallback: true
};
}
export async function getStaticProps(context) { const reportMaster = await daos.getReportMaster() let articles = await reportMaster.getArticleDataByCategory(context.params.category); if(!articles) return {notFound: true, };
return {props: {articles: JSON.stringify(articles), reportType: context.params.reportType, category: context.params.category}, revalidate: 3600};
} `
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
Problem is even I cannot reproduce it on my local machine. It gives no problem with hardcoded values. Issue is only if I pull from database. Let me come back if I can create a small repo to reproduce.
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.