Skip to content

GetStaticProps returning initial notFound never triggers a rebuild on revalidate with dynamic routes #21453

@alizeait

Description

@alizeait

What version of Next.js are you using?

10.0.5

What version of Node.js are you using?

12.13.0

What browser are you using?

Chrome

What operating system are you using?

Windows

How are you deploying your application?

next start

Describe the Bug

If getStaticProps returns notFound: true in the initial build with a revalidate value, Nextjs never tries to rebuild the page

Expected Behavior

Nextjs should try rebuilding the page instead of assuming permanent 404

To Reproduce

export const getStaticProps = async (props) => {
  try {
    const dictionaries = await apiFetch();
    return {
      props: {
        dictionaries,
      },
      revalidate: 60,
    };
  } catch (error) {
// assume the api fetch fails with the initial build
   return {
      notFound: true,
      props: {
        dictionaries: {},
      },
      revalidate: 60,
    };
  }

// On subsequent re-builds after revalidate has passed and the api returns a ok response, Nextjs never tries to rebuild the page and always returns the 404 page instead

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions