Skip to content

Commit

Permalink
Expose AsyncLocalStorage on global for react (#41683)
Browse files Browse the repository at this point in the history
For compat this needs to be exposed on global in the Node.js runtime as
well as discussed cc @sebmarkbage
  • Loading branch information
ijjk committed Oct 23, 2022
1 parent 374ca38 commit 0b921a6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/next/server/next-server.ts
Expand Up @@ -262,6 +262,12 @@ export default class NextNodeServer extends BaseServer {
isAppPath: false,
}).catch(() => {})
}

if (this.nextConfig.experimental.appDir) {
// expose AsyncLocalStorage on global for react usage
const { AsyncLocalStorage } = require('async_hooks')
;(global as any).AsyncLocalStorage = AsyncLocalStorage
}
}

private compression = this.nextConfig.compress
Expand Down

0 comments on commit 0b921a6

Please sign in to comment.