-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
"MaxListenersExceededWarning: Possible EventTarget memory leak detected" from fetch with AbortSignal #46525
Comments
See nodejs/undici#939. If I use undici directly, I get the If I use Node.js's built-in fetch (which I understand uses undici), I get the // Uncomment to compare implementations
//const {fetch} = require('undici');
async function main() {
const controller = new AbortController();
while (true) {
try {
await fetch('http://example.com', { signal: controller.signal });
} catch (e) {
}
}
}
main(); |
undici cleans up the listeners properly, the issue is that the signal is never being aborted and the gc won't run in the loop so the listeners aren't being removed instantly. |
Thanks for the reply, @KhafraDev. I'm not sure that that's what's going on - or maybe I'm not understanding things:
|
Version
v19.6.0
Platform
Darwin 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:03:51 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T6000 arm64 arm Darwin
Subsystem
fetch
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Every time
What is the expected behavior?
No errors or warnings
What do you see instead?
Additional information
It looks like Node's built-in
fetch
fails to properly clean up itsabort
listener when used with an AbortSignal.The text was updated successfully, but these errors were encountered: