Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/flags/src/next/dedupe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ export function dedupe<A extends Array<unknown>, T>(
): (...args: A) => Promise<T> {
const requestStore: RequestStore<T> = new WeakMap<Headers, CacheNode<T>>();

// 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<T> {
// 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);
Expand Down
Loading