-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Node warning after langchain upgrade to 0.2.13 Possible EventTarget memory leak detected. 11 abort listeners added to [AbortSignal]. MaxListeners is 10. Use events.setMaxListeners() to increase limit #6461
Comments
To resolve the "MaxListenersExceededWarning" in Node.js after upgrading LangChain to the latest versions, you can increase the maximum number of listeners for an event emitter. This can be done using the Here is an example of how you can set this up: const events = require('events');
events.EventEmitter.defaultMaxListeners = 20; // Set the maximum number of listeners to 20
// Alternatively, you can set it for a specific event emitter instance
const emitter = new events.EventEmitter();
emitter.setMaxListeners(20); This code sets the default maximum number of listeners to 20 for all event emitters. You can adjust the number as needed based on your application's requirements [1]. Additionally, the |
Hey @djaffer, thanks for reporting this - could you share the code that triggers this? |
(node:64750) MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 abort listeners added to [AbortSignal]. MaxListeners is 10. Use events.setMaxListeners() to increase limit
|
And then you pass a signal? |
updated response. I am not passing any signal. |
Will go live in next core release, thanks for flagging! |
Checked other resources
Example Code
Getting error when running langchain
Error Message and Stack Trace (if applicable)
(node:62032) MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 abort listeners added to [AbortSignal]. MaxListeners is 10. Use events.setMaxListeners() to increase limit
at [kNewListener] (node:internal/event_target:566:17)
at [kNewListener] (node:internal/abort_controller:240:24)
at EventTarget.addEventListener (node:internal/event_target:679:23)
at /home/langchainnode_modules/@langchain/core/dist/utils/signal.cjs:18:20
at new Promise ()
at raceWithSignal (/home/langchainnode_modules/@langchain/core/dist/utils/signal.cjs:17:9)
at RunnableMap._transform (/home/langchainnode_modules/@langchain/core/dist/runnables/base.cjs:1397:79)
at _transform.next ()
at RunnableMap._transformStreamWithConfig (/home/langchainnode_modules/@langchain/core/dist/runnables/base.cjs:307:30)
at _transformStreamWithConfig.next ()
at PromptTemplate.transform (/home/langchainnode_modules/@langchain/core/dist/runnables/base.cjs:390:26)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ChatOpenAI.transform (/home/langchainnode_modules/@langchain/core/dist/runnables/base.cjs:390:26)
at async wrapInputForTracing (/home/langchainnode_modules/@langchain/core/dist/runnables/base.cjs:274:30)
at async pipeGeneratorWithSetup (/home/langchainnode_modules/@langchain/core/dist/utils/stream.cjs:260:19)
at async StringOutputParser._transformStreamWithConfig (/home/langchainnode_modules/@langchain/core/dist/runnables/base.cjs:295:26)
Description
Getting the warning in node after upgrading langchain to latest versions.
"@langchain/community": "0.2.25",
"@langchain/openai": "0.2.6",
"langchain": "0.2.13",
System Info
"@langchain/community": "0.2.25",
"@langchain/openai": "0.2.6",
"langchain": "0.2.13",
The text was updated successfully, but these errors were encountered: