-
Notifications
You must be signed in to change notification settings - Fork 651
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
MaxListenersExceededWarning: Possible EventEmitter memory leak detected #694
Comments
Can you share runnable example code? |
That really shouldn't happen. There should only be one of those listeners on each event at a time. The specific retry code might help pinpoint what's going wrong there. |
Here's some pseudo code before we figure out a runnable test case:
|
I cannot figure out how to replicate this warning. I'm working on Linux but otherwise the environment is the same. I don't think I will be able to figure this out without specific code to reproduce it. |
Can you send an example of testable and reproducible code that you wanna see? It will help me to understand what you need. |
I'm just looking for a script or program or whatever that triggers this warning when you run it. |
I have received a user report in the It seems that every time _write is called, the client calls into the FilterStack. The DeadlineFilter then adds a connectivyStateChanged listener every time it is invoked. While I don't fully understand this codepath, it seems like this listener would only need be registered once. |
As an additional note, I can re-produce this reliably if I turn on package loss for my Wifi and run the following test: https://github.com/googleapis/nodejs-firestore/blob/master/dev/system-test/firestore.ts#L928 This test open 150 bidirectional streams over two HTTP2 channels, which I assume ends up calling Stacktrace:
|
I'm getting this error too, but since I need this working today, I'm going to change my plans from using the '@Google-Cloud' module. But here is my stacktrace:
|
|
This happens with my firestore node server setup always on startup (where I begin listening to several collections) ever since i upgraded to |
Seeing something potentially related here googleapis/nodejs-firestore#768 |
Problem description
Node warning observed
MaxListenersExceededWarning: Possible EventEmitter memory leak detected
when retrying connection for serverStreaming.Reproduction steps
'Internal HTTP2 error'
error when the grpc server is not availableEnvironment
Additional context
Adding
process.on('warning', e => console.warn(e.stack));
will show the stack trace.Above this line of code
https://github.com/grpc/grpc-node/blob/master/packages/grpc-js/src/channel.ts#L340
If we add
We see incrementing of
connect
listenerCountAdding
to
onConnect
function fix this incrementing, and also fix the error.Also noted is that for the first 2 or 3 retry the listeners doesn't increment. It only increment after a couple retrials.
I tried to dig down the root cause of this issue but couldn't trace it down. The suggested
removeListener
fix is low risk and would your guys consider this fix?The text was updated successfully, but these errors were encountered: