-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install AsyncLocalStorage for appDir rendering (vercel/turborepo#3374)
#44668 refactored Next's use of `AsyncLocalStorage`, and installs a "polyfill" of the API by patching the node import onto `globalThis.` Importantly, it's then used in the module scope during imports, so we need to install the polyfill early in the app rendering startup. Fixes vercel/turborepo#3319
- Loading branch information
1 parent
0417e52
commit 37c2aba
Showing
3 changed files
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Next.js now creates an AsyncLocalStorage in the module scope, meaning we | ||
// need to: | ||
// 1. Install it (it's accessed as `globalthis.AsyncLocalStorage`) | ||
// 2. Do it in an import (import ordering is guaranteed) | ||
import { AsyncLocalStorage } from "node:async_hooks"; | ||
globalThis.AsyncLocalStorage = AsyncLocalStorage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters