fix: MaxListenersExceededWarning for parallel tasks (shared AbortSignal) - #2573
Open
Arpan Das (adasarpan404) wants to merge 2 commits into
Open
fix: MaxListenersExceededWarning for parallel tasks (shared AbortSignal)#2573Arpan Das (adasarpan404) wants to merge 2 commits into
Arpan Das (adasarpan404) wants to merge 2 commits into
Conversation
… in parallel tasks
|
@langchain/langgraph-checkpoint
@langchain/langgraph-checkpoint-mongodb
@langchain/langgraph-checkpoint-postgres
@langchain/langgraph-checkpoint-redis
@langchain/langgraph-checkpoint-sqlite
@langchain/langgraph-checkpoint-validation
create-langgraph
@langchain/langgraph-api
@langchain/langgraph-cli
@langchain/langgraph
@langchain/langgraph-cua
@langchain/langgraph-supervisor
@langchain/langgraph-swarm
@langchain/langgraph-ui
@langchain/langgraph-sdk
@langchain/angular
@langchain/react
@langchain/svelte
@langchain/vue
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Affected issues:
Send()calls)Root Cause
In
PregelRunner, all tasks scheduled in the same superstep (parallel execution tick) receive the exact samecomposedAbortSignalviaconfig.signal.Each LLM invocation (e.g.
ChatOpenAI.invoke()) and HTTP client adds anabortlistener to this shared signal. When fan-out exceeds Node.js default limit of 10 listeners, the warning is emitted.This is not a real memory leak — it's Node.js protecting against potential leaks — but it creates noise in production and tutorial runs.
Solution
Fork the parent
AbortSignalfor each parallel task so every task gets its own cleanAbortSignalinstance while still fully propagating cancellation from the parent.Changes
AbortSignal.any()(modern & clean).Testing
MaxListenersExceededWarningwith 15+ parallel LLM calls.Ready for review! 🚀