-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(node): Auto-select best
AsyncContextStrategy
for Node.js versi…
…on (#7804) Co-authored-by: Abhijeet Prasad <[email protected]>
- Loading branch information
1 parent
53ae9ae
commit 4856685
Showing
3 changed files
with
21 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { NODE_VERSION } from '../nodeVersion'; | ||
import { setDomainAsyncContextStrategy } from './domain'; | ||
import { setHooksAsyncContextStrategy } from './hooks'; | ||
|
||
/** | ||
* Sets the correct async context strategy for Node.js | ||
* | ||
* Node.js >= 14 uses AsyncLocalStorage | ||
* Node.js < 14 uses domains | ||
*/ | ||
export function setNodeAsyncContextStrategy(): void { | ||
if (NODE_VERSION.major && NODE_VERSION.major >= 14) { | ||
setHooksAsyncContextStrategy(); | ||
} else { | ||
setDomainAsyncContextStrategy(); | ||
} | ||
} |
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