diff --git a/packages/flags/src/next/dedupe.ts b/packages/flags/src/next/dedupe.ts index b10f16b..6dc0976 100644 --- a/packages/flags/src/next/dedupe.ts +++ b/packages/flags/src/next/dedupe.ts @@ -53,10 +53,12 @@ export function dedupe, T>( ): (...args: A) => Promise { const requestStore: RequestStore = new WeakMap>(); + // async import required as turbopack errors in Pages Router + // when next/headers is imported at the top-level + const headersPromise = import('next/headers').then((mod) => mod.headers); + const dedupedFn = async function (this: unknown, ...args: A): Promise { - // async import required as turbopack errors in Pages Router - // when next/headers is imported at the top-level - const { headers } = await import('next/headers'); + const headers = await headersPromise; const h = await headers(); let cacheNode = requestStore.get(h);