Hello, I am trying SST for the first time and am d...
# help
r
Hello, I am trying SST for the first time and am depolying a site using the
NextjsSite
construct. A key use case for us is the ability to handle Incremental Static Regeneration, which is listed as one of the supported features. I have a simple NextJS site setup that has a page with a dynamic route configured (ie
/test/[id]
) and the following for
getStaticPaths
and
getStaticProps
-
Copy code
export const getStaticProps: GetStaticProps = async () => {
  return {
    props: {
      date: new Date().toString(),
    },
    revalidate: 10,
  };
};

export const getStaticPaths: GetStaticPaths = async () => ({
  paths: [],
  fallback: true,
});
The page simply displays the date. When running NextJS locally it behaves as expected; none of the pages are generated at build time, when you access a page you receive the same date for up to 10 seconds before it is re-validated and you receive a new date. However when I deploy to AWS the date for the page never changes after the initial generation. It stays the same. The headers are showing a CloudFront miss, and I can see the behaviour for the
data
route has a lambda configured. However I am unable to view logs for that lambda as there doesn't seem to be any log group that has been created, so I can't really tell if it's even being called. Any ideas? I am running Next 12. Thanks!
d
There should also be an SQS FIFO queue that lambda uses as a trigger, perhaps metrics for that will tell you if it’s being triggered?
You can also try setting
fallback
to
blocking
instead of true. This is unlikely to solve it, but perhaps worth a troubleshooting step.
This feature is critical to me, so I actually deployed two versions of your test, one with a param in the url path, one without. The non-param definitely works, confirmed with 3 updates. The param seems to also work. The behavior I see is that the original load will populate, then I will reload and it will refresh in the background. One more refresh gets the update. This seems quite intentional. Note that I used
fallback: "blocking"
.
SQS Monitoring
Logs
The log group was not created until it ran, of note.
f
@Derek Kershner thanks for looking into this. Did u test it with NextJS 12?
d
yes
"next": "^12.1.0",
r
Thanks Derek, I'll be able to look in to this further in my afternoon (Australia). Stuck in meetings all morning.
Ok so I checked the SQS monitoring and couldn't see any messages coming through. I swapped to
fallback: "blocking"
and re-deployed, now the site was acting as expected; and as you described. I could request a page and it would be generated, then another request after the
revalidate
period would return the same page, but a subsequent refresh would show the newly generated date. I checked SQS and could see messages being processed. I swapped back to
fallback: true
and re-deployed, and it this actually now appears to work as well, except one page of my 3 doesn't update, a little strange. I will investigate further to see what is going on there. Have you experimented with the new On-Demand Revalidation feature introduced in Next 12.1? https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration#using-on-demand-revalidation In the code it appears to just call the page URL with a special header to trigger regeneration - https://github.com/vercel/next.js/blob/57702cb2a9a9dba4b552e0007c16449cf36cfb44/packages/next/server/api-utils/node.ts#L310-L329 I'm hoping this may "just work" if the api route just calls the page route, which triggers the regenerate lambda which should include the relevant code? Or am I over simplifying things, haha. This is an important use case for me, we have a data set that has critical information in it that needs to be accurate. A situation where a page hasn't been accessed for some time (perhaps an hour) and a user receives a stale version is not really acceptable for our implementation. I guess the alternative is that we just go full SSR with these pages and adjust caching for them to take some heat of the lambda in high load.
d
Have you experimented with the new On-Demand Revalidation feature introduced in Next 12.1?
I have not, but I also am hoping it will “just work”.
Seems like it would be easy to integrate, even if it doesn’t.