next-runtime icon indicating copy to clipboard operation
next-runtime copied to clipboard

[Bug]: Generated path is not deleted from CDN

Open michalklim opened this issue 2 years ago • 0 comments

Summary

Seems like already generated paths are kept on CDN indefinitely. I'm using one catch-all route /[[...paths]] to handle all of the paths on the site. Paths are obtained from the CMS through getStaticPaths with fallback set to blocking:

export const getStaticPaths = async () => {
  const paths = await getPaths()

  return {
    paths,
    fallback: 'blocking',
  }
}

Next those are validated in getStaticProps. If no data is present for the path getStaticProps returns:

return {
  notFound: true
}

if there is a data getStaticProps returns:

return {
    props: {
       // some props 
    },
    revalidate: 10,
}

Whenever path is deleted (ie user removed a site in CMS) it is still available and Netlify returns 304 status for this path corresponding props json file when accessed directly and 200 status if navigated to.

There are no errors in functions logs.

Same is happening if I return an empty paths array from getStaticPaths:

export const getStaticPaths() => {
  return {
    paths: [ ],
    fallback: 'blocking',
  }
}

Redeploying the site fix the issue (I assume, because it flushes the CDN?)

Steps to reproduce

  1. Create a path with some data and make sure it was actually generated (in case of empty paths array)
  2. Remove that path
  3. Site should be still served from Netlify

A link to a reproduction repository

No response

Plugin version

4.7.0

More information about your build

  • [ ] I am building using the CLI
  • [X] I am building using file-based configuration (netlify.toml)

What OS are you using?

Mac OS

Your netlify.toml file

`netlify.toml`
# Paste content of your `netlify.toml` file here

Your public/_redirects file

`_redirects`
# Paste content of your `_redirects` file here

Your next.config.js file

`next.config.js`
# Paste content of your `next.config.js` file here. Check there is no private info in there.

Builds logs (or link to your logs)

Build logs
# Paste logs here

Function logs

Function logs
# Paste logs here

.next JSON files

generated .next JSON files
# Paste file contents here. Please check there isn't any private info in them
# You can either build locally, or download the deploy from Netlify by clicking the arrow next to the deploy time.

michalklim avatar May 18 '22 11:05 michalklim