Files
triggershell/src/bootstrap/async-local-storage-polyfill.ts
T

10 lines
545 B
TypeScript
Raw Normal View History

2026-08-15 18:37:30 +02:00
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;
}