-
-
Notifications
You must be signed in to change notification settings - Fork 688
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
There is still a memory leak in Agent.
Reproducible By
const { Agent, fetch, setGlobalDispatcher } = require('undici');
const agent = new Agent({
keepAliveMaxTimeout: 1000,
});
setGlobalDispatcher(agent);
globalThis.agent = agent;
async function main() {
const rs = await Promise.all([
fetch('http://www.example.com/123'),
fetch('http://example.com/234'),
fetch('https://www.example.com/345'),
fetch('https://example.com/456'),
]);
console.log('done')
setTimeout(() => undefined, 1000000)
}
void main();Run the script with --inspect. After 'done', inspect agent[kClients]. There will be 4 items in the map.
Expected Behavior
All clients should have been destroyed.
Logs & Screenshots
Environment
Undici 7.14.0, Nodejs 22.16.0.
Additional context
In Agent::[kDispatch] the key of this[kClients] is a string, but in Agent::[kOnConnect] and Agent::[kOnDisconnect] the origin is a URL object. Even if it is coerced into a string, there will be a trailing slash which makes it different from the original key.
styfle and Filipoliko
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working