4d20beb7c5
Ref: [Slack thread](https://vercel.slack.com/archives/C035J346QQL/p1666056382299069?thread_ts=1666041444.633059&cid=C035J346QQL), [docs update](https://github.com/vercel/front/pull/17090) Spec: https://wicg.github.io/cookie-store/ BREAKING CHANGE: Ref: https://github.com/vercel/edge-runtime/pull/177, https://github.com/vercel/edge-runtime/pull/181 ## Bug - [ ] 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 lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
18 lines
506 B
TypeScript
18 lines
506 B
TypeScript
import type { AsyncLocalStorage } from 'async_hooks'
|
|
import type {
|
|
ReadonlyHeaders,
|
|
ReadonlyRequestCookies,
|
|
} from '../../server/app-render'
|
|
|
|
export interface RequestStore {
|
|
headers: ReadonlyHeaders
|
|
cookies: ReadonlyRequestCookies
|
|
previewData: any
|
|
}
|
|
|
|
export let requestAsyncStorage: AsyncLocalStorage<RequestStore> | RequestStore =
|
|
{} as any
|
|
|
|
if (process.env.NEXT_RUNTIME !== 'edge' && typeof window === 'undefined') {
|
|
requestAsyncStorage = new (require('async_hooks').AsyncLocalStorage)()
|
|
}
|