10 lines
545 B
TypeScript
10 lines
545 B
TypeScript
import { AsyncLocalStorage } from "node:async_hooks";
|
|||
|
|
|
||
|
|
// Next's App Router needs this global set up before its own modules evaluate. `next start`/`next dev`
|
||
|
|
// do this via their CLI bootstrap; the programmatic `next()` API used by our custom server does not.
|
||
|
|
// Must be the first import in server.ts - ESM import evaluation order (not textual position) is what
|
||
|
|
// guarantees this runs before the `next` package's module graph does.
|
||
|
|
if (typeof globalThis.AsyncLocalStorage !== "function") {
|
||
|
|
globalThis.AsyncLocalStorage = AsyncLocalStorage;
|
||
|
|
}
|