next.js
b8d1ef75 - Wire AsyncLocalStorage within a cached context (#70573)

Commit
1 year ago
Wire AsyncLocalStorage within a cached context (#70573) This ensures we exit the RequestStorage/PrerenderStorage context and anything else but keeps the StaticGenerationStore (which should no longer have page/request specific information). I also create new CacheStore which will be used for life/tags but for now is just used to provide a better error when cookies/headers/draftMode are accessed within the cache scope. I tried to make `React.cache` AsyncLocalStorage scope be shared between the invocation of the cached function and anything it renders later. This is also necessary in case the cached function calls Float methods like `preload()`. However, I hit issues with preserving debug info, having the right owner and that rendering a Promise in a Server Component turns it into a `React.lazy` for now which doesn't preserve the type we want. The proper solution is for React to expose a larger scope for `React.cache` and float.
Author
Parents
Loading