-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core[minor]: Allow injection of AsyncLocalStorage #4498
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
I actually think it might be better to instantiate a singleton instance instead of a class - don't think there are any downsides to sharing an instance? Going to change to that to remove janky race condition around instantiating a global variable in the constructor. |
run: (store: any, callback: () => any) => any; | ||
} | ||
|
||
export class MockAsyncLocalStorage implements AsyncLocalStorageInterface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure Mock
is the right word to use here? To me if I see this I'll assume it should be used in tests, and not as the default value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a mock though because it's not doing anything? Any better names?
@nfcampos how's this look? |
AsyncLocalStorage
a very useful API that is available in many environments but not all. We want to allow projects like LangGraph to take advantage of its convenience at the cost of supporting only a subset of environments.The idea would be (before instantiating any
RunnableLambda
):This PR also allows nested
RunnableLambdas
to automatically fetch config from the next level up, enabling more convenient tracing.@nfcampos @bracesproul @dqbd