Skip to content

Commit

Permalink
feat(js): Validate that store values are RunTree instances (#1088)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 authored Oct 11, 2024
1 parent 2bf5482 commit 3c697ab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions js/src/singletons/traceable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RunTree } from "../run_trees.js";
import { isRunTree, RunTree } from "../run_trees.js";
import { TraceableFunction } from "./types.js";

interface AsyncLocalStorageInterface {
Expand Down Expand Up @@ -47,7 +47,7 @@ export const AsyncLocalStorageProviderSingleton =
*/
export const getCurrentRunTree = () => {
const runTree = AsyncLocalStorageProviderSingleton.getInstance().getStore();
if (runTree === undefined) {
if (!isRunTree(runTree)) {
throw new Error(
[
"Could not get the current run tree.",
Expand Down
2 changes: 1 addition & 1 deletion js/src/traceable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ export function traceable<Func extends (...args: any[]) => any>(
// Node.JS uses AsyncLocalStorage (ALS) and AsyncResource
// to allow storing context
const prevRunFromStore = asyncLocalStorage.getStore();
if (prevRunFromStore) {
if (isRunTree(prevRunFromStore)) {
return [
getTracingRunTree(
prevRunFromStore.createChild(ensuredConfig),
Expand Down

0 comments on commit 3c697ab

Please sign in to comment.