Skip to content

Commit

Permalink
Check for AsyncLocalStorage support
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannes Bornö committed Feb 28, 2023
1 parent 12118b4 commit 16357b3
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/next/src/server/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1500,11 +1500,18 @@ export async function renderToHTML(
)
}

return runWithRenderContextAsyncStorage(
renderContextAsyncStorage,
{ pathname },
() => wrappedRender()
)
const supportRenderContextStorage =
typeof (globalThis as any).AsyncLocalStorage === 'function'

if (supportRenderContextStorage) {
return runWithRenderContextAsyncStorage(
renderContextAsyncStorage,
{ pathname },
() => wrappedRender()
)
} else {
return wrappedRender()
}
}

export type RenderToHTMLResult = typeof renderToHTML

0 comments on commit 16357b3

Please sign in to comment.