Skip to content

Commit

Permalink
Remove type dependency on AsyncLocalStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
dqbd committed May 14, 2024
1 parent 11dc76f commit 55a46b0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions js/src/traceable/context.ts
Original file line number Diff line number Diff line change
@@ -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<RunTree | undefined>;
let storage: AsyncStorageLike;

return {
register: (value: AsyncLocalStorage<RunTree | undefined>) => {
register: (value: AsyncStorageLike) => {
storage ??= value;
return storage;
},
Expand Down

0 comments on commit 55a46b0

Please sign in to comment.