-
Notifications
You must be signed in to change notification settings - Fork 540
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
Memory issues / many instances of MaxListenersExceededWarning when using Undici via Elasticsearch #3131
Comments
It's quite possible that there is some other reason that my service is running out of memory and dying. But at any rate, it would be good for us to get to the bottom of the MaxListenersExceededWarnings, which (as far as I can tell, from my limited understanding) appear to suggest a memory leak somewhere in Undici. |
I believe I open end an issue over at elasticsearch a long time ago. They don't properly cleanup signals. |
Just one remark: when running the wpt suite for fetch, i see the MaxListenersExceededWarning emitted too. |
Thanks for pointing this out @ronag. Seems I didn't address your comment there when I initially thought the problem was resolved in elasticsearch 8.8.1. |
is this fixed? |
Not in the Elasticsearch client, yet. I have to run down what @ronag suggested and establish the best way to fix that without introducing any breaking changes. Updates will be shared on elastic/elastic-transport-js#63. |
|
Bug Description
This is a follow-up to #1711. @KhafraDev asked that I file a separate issue because Elasticsearch does not appear to be using
fetch
, which is what was fixed in that issue (via #2823).I've been running into what I think is the same or similar issue to what was reported in #1711 - lots of MaxListenersExceededWarnings being logged, and my service eventually runs out of memory and dies. When I run with
--trace-warnings
, the stacktrace points to Undici:This is with Undici 6.13.0, which is a transitive dependency of
@elastic/transport
8.5.0.Reproducible By
I would be happy to provide a minimal repro case if I had any idea how to do that! :)
Please let me know if you have any ideas of things I can test in my setup.
Expected Behavior
Environment
Local
2021 Macbook Pro M1 Max
macOS Sonoma 14.11
Node 20.9.0
I'm seeing the MaxListenersExceededWarnings when I run my service locally.
Deployed
My service is also running on a Linux server, in a Docker container with Node 20. I'm also seeing the MaxListenersExceededWarnings logged there, and the memory graph shows a significant decline in memory usage from the time the instance spins up to when it eventually runs out of memory and dies.
Additional context
I don't fully understand what @KhafraDev meant by Elasticsearch not using
fetch
. I looked through the@elastic/transport
code base (on thev8.5.0
tag, which is the version I'm using) and I found UndiciConnection.ts, which appears to be where it's creating an Undici pool and callingrequest
on it, but beyond that, I'm not sure what to look for.The text was updated successfully, but these errors were encountered: