Description
Link to the code that reproduces this issue
https://github.com/m-rphy/nextMemoryLeak
To Reproduce
-
In one terminal and
cd
into the/express_server
and runnpm start
-
In a sperate teminal
cd
in/next_app
and runnpm run inspect
-
Using any browser go to either
http://localhost:3000/start-fetch
orhttp://localhost:3000/start-custom-fetch
to begin the requests. -
Then open chrome inspect (
chrome://inspect
) or use any other debugging tools.
I believe this is ticket is also relevant - but this repo reproduces it with and avoids it -> #54708
Current vs. Expected behavior
Next.js's global fetch is holding onto performance metrics or some other data that is leading to heap growth after every requests.
The heap should not grow after the scope closes.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:49 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6020
Available memory (MB): 16384
Available CPU cores: 10
Binaries:
Node: 20.10.0
npm: 10.2.3
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 14.2.0-canary.62 // Latest available version is detected (14.2.0-canary.62).
eslint-config-next: 14.1.4
react: 18.2.0
react-dom: 18.2.0
typescript: 5.4.4
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Not sure, Data fetching (gS(S)P, getInitialProps)
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local), Other (Deployed)
Additional context
I've tested this repo against different canary releases (canary-32 and canary-62), as well as Next.js lts.
I haven't been able to find a version that works.