I am working on NextJS project with TypeScript. For some strange reasons it is failing to compile either for development or production. It fails with timeout error as shown in the following error trace
> Build error occurred
Error: Static page generation for /posts/introducing-hapana-v1 is still timing out after 3 attempts. See more info here https://nextjs.org/docs/messages/static-page-generation-timeout
at onRestart (/app/node_modules/next/dist/build/index.js:487:31)
at Worker.exportPage (/app/node_modules/next/dist/lib/worker.js:49:40)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async /app/node_modules/next/dist/export/index.js:412:32
at async Span.traceAsyncFn (/app/node_modules/next/dist/trace/trace.js:74:20)
at async Promise.all (index 3)
at async /app/node_modules/next/dist/export/index.js:407:9
at async Span.traceAsyncFn (/app/node_modules/next/dist/trace/trace.js:74:20)
at async /app/node_modules/next/dist/build/index.js:987:17
This following is the dynamic page [slug].tsx
const PostDetailsPage: React.FC<PostDetailsProps> = (props) => {
// console.log(post);
const { post, posts } = props;
if (!post || !posts) return <Loader />;
return <Post post={post} posts={posts} />;
};
export async function getStaticProps(context: any) {
const slug = context.params.slug;
const { data: postData } = await getPost(slug);
const { data: posts }: DataInterface = await getBlogPosts(1);
return {
props: {
post: postData,
posts: posts.results,
},
};
}
export async function getStaticPaths() {
const { data: posts }: DataInterface = await getBlogPosts(1);
const slugs = posts.results.map((p) => ({ params: { slug: p.slug } }));
return {
paths: slugs,
fallback: true,
};
}
export default PostDetailsPage;
export const getBlogPosts = (page: number) => {
return http.get(apiEndpoint + `posts/?cats=blog&page=${page}`);
};
export const getPost = (postSlug: string) => {
return http.get(postUrl("posts/" + postSlug + "/"));
};
Please note http
is just an axios interceptor function
Could anyone help me resolve this issue?