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.
@mcollina I was able to finally get a minimal reproduction without using next or react
https://github.com/snyamathi/undici-mem-leak
Looking at the chart, it does indeed appear to be a memory leak but it seems to be specific to Node's
AsyncLocalStorage
which is something that I dug out of the React source code hereThis may actually have a root issue in Node itself which the team may want to be aware of - it seems like the reference prevents garbage collection so this same bug could bite others using
AsyncLocalStorage
in the same way.The test is a little round-a-bout in its testing, but it tries to assert that the body is garbage collected by checking that the weak ref becomes
undefined
.This test fails before the change that I put in, and only succeeds after.
I have the reproduction setup to test multiple versions of
undici
and show the problem does not exist in 6.15.0, does exist in 6.16.0 and is then fixed in 6.19.7 - check out the repo link above, but it looks like this:related to #3445