98106ba8d2
Follow-up to https://github.com/vercel/next.js/pull/41402 this re-enables the sandbox cache and updates to leverage our global `AsyncLocalStorage` for isolating request meta in both the edge and Node.js runtime. Closes: https://github.com/vercel/next.js/issues/42349 Closes: https://github.com/vercel/next.js/issues/38235 Closes: https://github.com/vercel/next.js/issues/42225 Closes: https://github.com/vercel/next.js/issues/42351 ## Bug - [x] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
19 lines
519 B
TypeScript
19 lines
519 B
TypeScript
import type { AsyncLocalStorage } from 'async_hooks'
|
|
|
|
export interface StaticGenerationStore {
|
|
inUse?: boolean
|
|
pathname?: string
|
|
revalidate?: number
|
|
fetchRevalidate?: number
|
|
isStaticGeneration?: boolean
|
|
}
|
|
|
|
export let staticGenerationAsyncStorage:
|
|
| AsyncLocalStorage<StaticGenerationStore>
|
|
| StaticGenerationStore = {}
|
|
|
|
// @ts-expect-error we provide this on global in
|
|
// the edge and node runtime
|
|
if (global.AsyncLocalStorage) {
|
|
staticGenerationAsyncStorage = new (global as any).AsyncLocalStorage()
|
|
}
|