-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Open
Description
Description
Hey Travis 👋🏻, thanks for your amazing work in this boilerplate!
I was giving this starter a try and noticed an unexpected behavior. When creating new pages in Notion after the first build, these new pages return 404 error for a while.
This seems to be related with resolveNotionPage function at line 51, precisely at this memoized getAllPages. The pMemoize cacheKey property will always be the same because it's not bind to the requested page id.
As a result, the canonicalPageMap will be stale.
Steps to reproduce
- Do a deploy
- Create a new page
- Wait NextJs 10 seconds revalidation time
- Try to access this new created page
- You should be redirect to 404
Screen.Recording.2022-06-03.at.20.41.11.mov
Proposed solution
I didn't find any infos about how p-memoize invalidates it's cache in the docs, so a solution to this may be using expiry-map and the same 10 seconds revalidate time.
const cache = new ExpiryMap(10000)
const getAllPages = pMemoize(getAllPagesImpl, {
cacheKey: (...args) => JSON.stringify(args),
cache
})Metadata
Metadata
Assignees
Labels
No labels