From 55a46b0159b2efb919506b322ab47868d8802fac Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Wed, 15 May 2024 00:29:27 +0200 Subject: [PATCH] Remove type dependency on AsyncLocalStorage --- js/src/traceable/context.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/js/src/traceable/context.ts b/js/src/traceable/context.ts index c646f3cef..f622da37e 100644 --- a/js/src/traceable/context.ts +++ b/js/src/traceable/context.ts @@ -1,11 +1,16 @@ -import { type AsyncLocalStorage } from "node:async_hooks"; import { RunTree } from "../run_trees.js"; +interface AsyncStorageLike { + getStore: () => RunTree | undefined; + + run: (context: RunTree | undefined, fn: () => void) => void; +} + export const TraceableLocalStorageContext = (() => { - let storage: AsyncLocalStorage; + let storage: AsyncStorageLike; return { - register: (value: AsyncLocalStorage) => { + register: (value: AsyncStorageLike) => { storage ??= value; return storage; },