-
Notifications
You must be signed in to change notification settings - Fork 587
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 leak with native fetch on Node v19+ #2143
Comments
Because it was moved to |
Does it eventually lead to a crash, or is it just an increase in memory usage? |
I ran it only for 360s and the only thing I noticed is the increase of memory usage. I also updated kamilkisiela/graphql-hive repo to Node 20 and we got to OOM pretty quickly there (but it’s another memory leak, related to http module of node, not fetch api but these two might be related). |
Did you take only two snapshots of each case? For the behavior... I'll try to visit this one this week |
I haven't went deep there, just noticed a memory leak and reproduced it. I only looked at the memory usage twice, right after sending low amount of traffic to warm the server and then right after sending huge traffic. |
Based on the data we have, this doesn't look like a leak but rather an increase in memory usage. Given this happens across different versions of Node.js/V8, it would likely be a change in the garbage collector algorithm, and nothing something we are responsible for. Note that fetch requires a few "bad" patterns that are hard on the GC (finalizers). |
Let's say I run it now for 6 minutes (as I did), then 12 and 24 minutes and the memory keeps increasing. It would mean it's a leak no? |
Can you try running |
Just to clarify, the reproduction is:
The memory goes up after each step. I could run 3rd step 10 more times and I believe the memory will goes up as well and at some point it will go to space with Elon (OOM). |
No it does not mean it's a leak. When V8 is under pressure CPU-wise, it tends to not cleanup memory unless it is absolutely needed. This happens after memory is transferred to "old space". The command @targos mentioned will definitely shows if there are issues. |
Version
v20.2.0
Platform
Subsystem
No response
What steps will reproduce the bug?
README.md
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
Constant memory usage
What do you see instead?
Increase in memory (heap snapshots available)
Additional information
To reproduce the memory leak I created a simple
node:http
server that calls nativefetch()
on every incoming HTTP request.I ran a load test against that server and measured the memory (heap snapshots available in the repository).
Next, I ran the same steps for Node v18.16 to compare the memory consumption.
It seems like Node v19, v20 are leaking but v18 seems stable.
Node v20.2
Native fetch
Undici v5.22.1
Node v18.16
Native fetch
Undici v5.22.1
Related to nodejs/node#47936
The text was updated successfully, but these errors were encountered: