mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-10 04:19:32 +00:00
fix: import node:async_hooks directly (#5198)
This commit is contained in:
@@ -6,18 +6,10 @@ import type { AsyncLocalStorage } from "node:async_hooks";
|
|||||||
// We only export the type here to avoid issues in environments where AsyncLocalStorage is not available.
|
// We only export the type here to avoid issues in environments where AsyncLocalStorage is not available.
|
||||||
export type { AsyncLocalStorage };
|
export type { AsyncLocalStorage };
|
||||||
|
|
||||||
/**
|
|
||||||
* Dynamically import AsyncLocalStorage to avoid issues in environments where it's not available.
|
|
||||||
*
|
|
||||||
* Right now, this is primarily for Cloudflare Workers.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
let moduleName: string = "node:async_hooks";
|
|
||||||
|
|
||||||
const AsyncLocalStoragePromise: Promise<typeof AsyncLocalStorage> = import(
|
const AsyncLocalStoragePromise: Promise<typeof AsyncLocalStorage> = import(
|
||||||
/* @vite-ignore */
|
/* @vite-ignore */
|
||||||
/* webpackIgnore: true */
|
/* webpackIgnore: true */
|
||||||
moduleName
|
"node:async_hooks"
|
||||||
)
|
)
|
||||||
.then((mod) => mod.AsyncLocalStorage)
|
.then((mod) => mod.AsyncLocalStorage)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user