You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Darwin xxx.xxx.ts.net 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:09:52 PDT 2024; root:xnu-10063.121.3~5/RELEASE_X86_64 x86_64
Subsystem
fetch
What steps will reproduce the bug?
This leak seems to require several factors:
Node v20.16.0 (does not reproduce in v20.15.1)
dd-trace npm module
Native fetch (does not reproduce with node-fetch)
Attaching a response from fetch to the Express request object
If any of these factors are missing, there is no leak. I'm not sure whether this would better be understood as a defect in Node.js or in dd-trace. The event that triggered this leak in our case was the upgrade from Node v20.15.1 to Node v20.16.0.
docker run -p 3001:80 -d kennethreitz/httpbin (server to respond to the fetch requests)
node --max-old-space-size=50 repro.mjs with repro.mjs having the following content:
// Run with Node 20.15.1 to fix the issueimport'dd-trace/init.js';// Or: comment this line to fix the issueimportexpressfrom'express';// import fetch from 'node-fetch'; // Or: uncomment this line to fix the issueconstapp=express();app.get('/',async(req,res)=>{try{constresponse=awaitfetch('http://localhost:3001/json');req.response=response;// Or: comment this line to fix the issueres.json({});}catch(err){res.status(500).json({error: err.message});}});app.listen(3000,()=>{console.log(`Server listening on port 3000`);});
Use autocannon to spam requests: npx autocannon -m GET -d 1000 'http://localhost:3000'
The server should crash with an out-of-memory error, it only takes around 10 seconds for me.
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
No OOM crash, as that is the behavior of the previous LTS release of Node.js.
It seems likely that this is triggered by an update of undici in Node core as mentioned in this issue: #54274 (comment)
But it seems like a distinct issue.
The text was updated successfully, but these errors were encountered:
avivkeller
added
memory
Issues and PRs related to the memory management or memory footprint.
fetch
Issues and PRs related to the Fetch API
labels
Aug 14, 2024
Version
v20.16.0
Platform
Subsystem
fetch
What steps will reproduce the bug?
This leak seems to require several factors:
dd-trace
npm modulefetch
to the Expressrequest
objectIf any of these factors are missing, there is no leak. I'm not sure whether this would better be understood as a defect in Node.js or in
dd-trace
. The event that triggered this leak in our case was the upgrade from Node v20.15.1 to Node v20.16.0.To reproduce:
npm i [email protected] [email protected]
(and optionally [email protected] if you want to confirm that node-fetch does not trigger the leak)docker run -p 3001:80 -d kennethreitz/httpbin
(server to respond to the fetch requests)node --max-old-space-size=50 repro.mjs
withrepro.mjs
having the following content:npx autocannon -m GET -d 1000 'http://localhost:3000'
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
No OOM crash, as that is the behavior of the previous LTS release of Node.js.
What do you see instead?
OOM crash:
Additional information
It seems likely that this is triggered by an update of undici in Node core as mentioned in this issue: #54274 (comment)
But it seems like a distinct issue.
The text was updated successfully, but these errors were encountered: