context.js 714 B

12345678910111213
  1. /* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */
  2. /**
  3. * This file exists as a convenient public entrypoint for functionality
  4. * related to context variables.
  5. *
  6. * Because it automatically initializes AsyncLocalStorage, internal
  7. * functionality SHOULD NEVER import from this file outside of tests.
  8. */
  9. import { AsyncLocalStorage } from "node:async_hooks";
  10. import { AsyncLocalStorageProviderSingleton } from "./singletons/index.js";
  11. import { getContextVariable, setContextVariable, registerConfigureHook, } from "./singletons/async_local_storage/context.js";
  12. AsyncLocalStorageProviderSingleton.initializeGlobalInstance(new AsyncLocalStorage());
  13. export { getContextVariable, setContextVariable, registerConfigureHook, };