You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Commit 680c7c4 added memoized the fetch for OpenAPI JSON in the
`resolveOpenAPI` function, but that particular implementation caused some
problems with the build output. Some of the pages in the API section went
missing.
The previous implementation was susceptible to a bit of a race condition, since
the cached value wasn't set until after several async calls. When Next tries to
aggressively build pages, multiple calls could have gotten through to do live
calls, and then all of them would have tried to set the cache variable. I don't
know the exact pathway to the issue but I suspect this had something to do with
the missing pages (some sort of data corruption?). Sorry, I know this is handwavy.
Anyway, replacing that implementation with a more robust one - one that caches
a promise on the first call, and reuses that promise on all future calls - will
definitely only fetch once per process. When the fetch completes, everyone
waiting on the promise will awaken, and then future callers of the method will
get a resolved promise for immediate results.
And, most importantly, this method of caching doesn't cause the `api/auth` and
`api/guides` pages to go missing.
0 commit comments