NextJS ISR stopped working 31/7

Hi,

We have been happily using Netlify for years, hosting multiple sites with Next.js and leveraging ISR for rebuilding. This setup has worked flawlessly for the past 2.5 years, but it suddenly stopped functioning correctly on Monday, 29/7.

Affected sites

All our NextJS sites are equally affected, one example: goboat-website-germany, running NextJS version 12.1.6

Issue description

By “not working,” I mean that the site does not incrementally update in the background.

Code snippets

This is our getStaticProps function:

export const getStaticProps: GetStaticProps = async (context) => {
  const variables: GetResourceQueryVariables = {
    key: getKey(context),
    target: context.preview ? 'draft' : 'live',
    siteId,
    type: 'page',
  };

  // this fetches data from our content service
  const data = await getWithRetries('getResource', variables);

  const now = new Date().toISOString();

  if (!data.resource) {
    return {
      notFound: true,
    };
  }

  return {
    props: {
      data,
      now,
    },
    revalidate: 60,
  };
};

And our page component is something like this:

const Page: NextPage<PageProps> = (props) => {
  const content = props?.data?.resource?.content ?? {};

  // this console log allows us to see when the page was generated
  console.log('Site last built:', props.now);

  return (
    <>
      <DynamicModuleGenerator content={content} />
    </>
  );
};

Observations

Visiting Mieten Sie ein Boot in Berlin - GoBoat Germany, at the moment, we see the log:

Site last built: 2024-07-09T12:09:10.310Z

Changes made in our CMS are not reflected on the website, as it does not rebuild in the background as expected.

When we manually trigger a rebuild, getStaticProps runs correctly, pulling in the latest content from the CMS and updating the timestamp.

Steps Taken

  • Cleared cache and triggered rebuild
  • Purged cache using an API call
  • Checked logs of the ISR function (found nothing obvious, logs available for only the last 7 days)

The above steps were attempted on goboat-website-denmark without success. As our editors frequently trigger rebuilds on that site, I felt goboat-website-germany serves as a better example since it is mostly left alone.

Timeline

On Monday, 29/7, our editors noted that changes made in the CMS no longer appeared on the website, with all content reverting to a state from about 3 weeks prior (the time of our latest manually triggered deployment).

Suspicions

We did not make any changes to our websites, code, or configuration during this period, leading me to believe the issue lies with Netlify.

I have read about a new runtime rollout for Next.js. Since we are using a version lower than 13.5, I assumed it wouldn’t affect us, but perhaps it has?

Request for Assistance

Could anyone shed light on this issue or suggest further steps to diagnose and resolve it? Any insights would be greatly appreciated.

Thanks, Elias

2 Likes

UPDATE: Upgrading to Next.js 13 + runtime v5 is now correctly handling ISR changes. :+1:

I also ran into this issue recently on a couple of sites that have ISR and use Contentful as the CMS. Next.js version 12.3.1.

I first followed the documentation for the Next.js Runtime to stay on v4 here: Next.js 13.5+ on Netlify | Netlify Docs But results in the same issue.

It may be that it is no longer supported as there is a note about On-Demand ISR for older Next.js versions: Next.js ISR on Netlify | Netlify Docs

On-demand ISR (where a path is manually revalidated) is only supported for Next.js 13.5 and later and Next.js Runtime v5.

As next steps I’ll be upgrading my sites to a more recent version of Next.js+runtime.

Small update from me:

We don’t do on-demand ISR, so that doesn’t matter for us. According to the Netlify NextJS docs, ISR is supported for Next.js version 10-13.4 and Next.js Runtime v4, which is in ‘maintenance support’.

However, after my dealings directly with Netlify tech support, it seems that ‘maintenance support’ means ‘no support’, as they refuse to even investigate the issue if we don’t upgrade to the latest NextJS version.

Upading to NextJS v13 is supposed to be straightforward, but I have spent two days trying to make it work on the Netlify runtime.

Unforunately there seems to be a bunch of undocumented breaking changes, such as the useRouter hook now throwing an error if used at all during SSG. After a long and painful refactoring to account for that, I finally hit the wall on the following issue:

2:15:06 PM: Error: <Html> should not be imported outside of pages/_document.
2:15:06 PM: Read more: No Document Import in Page | Next.js
2:15:06 PM: at ei (/opt/build/repo/frontends/website/node_modules/next/dist/compiled/next-server/pages.runtime.prod.js:38:4358)
2:15:06 PM: at Html (/opt/build/repo/frontends/website/.next/server/chunks/859.js:6:1327)

This despite not using <Html> or anything from ‘next/document’ outside of /pages/_document.tsx - an infuriating issue, to say the least.

The experience with Netlify support has also been incredibly frustrating, and insisting that we upgrade from a version that they allegedly support, before offering any help, feels very unprofessional.

As the ISR is working fine with exactly the same old NextJS version on Vercel, I am very much tempted to make the switch.

Sorry to carry the disappointing news for you multiple times, but currently we don’t have resources to allot to continue working on Next.js 12 issues. Next.js 13 was released about 2 years ago. Given that you’re still using Next.js 12, I assume that’s because you and your team have had some other priorities other than the upgrade. Similarly, Netlify is currently actively invested in supporting modern Next.js versions and would definitely prioritise any issues encountered on v5 Runtime. We do not have resources to allocate to support legacy systems.

This is not to say there’s no issue, there could be something wrong on our end, however if it’s working fine on v5, we’d be less inclined to allocate resources to investigate and fix why it’s broken on v4.

That is all fair and well - we just wish you could have given an official deprecation notice, giving us a deadline for when to upgrade. Having this critical failire of a supposedly supported version (you call it “maintenance support” - ie it should be maintained), and then a total refusal of support, is just hard to stomach.

When we read about the new NextJS runtime rollout, we did not see anything about v12 being deprecated, but maybe we missed something?

The issue might potentially be fixed now if you re-deploy.

This issue is far from resolved.

It’s completely unacceptable that this deprecation was implemented without any prior notice. According to your official documentation, ISR is still supported on lower versions of Next.js.

We have over 100 websites hosted on your platform running Next.js v12. This sudden change has created a significant disruption, and it’s now a major challenge for us to address this unexpected mess.

The issue appears to have been resolved, ISR for our websites is back and working as normal. Thank you.

1 Like

glad to hear your issues have been resolved. Thanks for writing back in.