-
Notifications
You must be signed in to change notification settings - Fork 540
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
cleanup listener for user provided AbortSignal #939
Comments
The |
@benjamingr weak listeners would be nice here 😄 |
This has been marked completed for a while now, and I assume node 18.10.0 uses the version of undici that has this issue marked as closed/completed. Running on 18.10.0 the code below gets me a const ac = new AbortController();
for (let i = 0; i < 11; i += 1) {
const response = await fetch("https://www.google.com", { signal: ac.signal });
if (!response.ok) {
throw new Error("For some reason fetch failed, make sure it doesn't");
}
console.log(i + 1);
} I am writing a module for OAI-PMH lists which rely on fetching consecutively until a certain response is given. I want to be able to abort the current fetch with the same controller as I would have the previous, but currently that is not a good idea because fetch doesn't clean up the listener it registered on the signal it seems. |
Copying from another issue: 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. @ronag is there anything we can do here? |
I don't really see a good way here... the spec doesn't really address this issue properly... |
deno has the same issue, there just isn't a warning. Should we raise/remove the limit? |
I guess soo... maybe raise it to 100? |
isn't there kind of a root problem with the AbortController/AbortSignal specification in itself? not just about fetch. it feels to me that if the AbortController is GC then it up to the AbortController job to also remove all event listener on the AbortSignal b/c there are no longer any way for it to be aborted. so registering new listeners should also not do anything? ofc there is the method of manually dispatching own events... feels like |
The abortcontroller isn't being gc'ed, each fetch adds a new abort listener to the abortsignal which is where we get the issue. Now, those listeners are eventually being gc'ed (add a globalThis.gc?.() with --expose-gc and the warnings go away), but it's not happening within the loop. |
We shipped a new |
Could this still be an issue? See #1711. |
If I understand correctly this is a "won't fix", as it's more of a spec issue. |
Refs: whatwg/fetch#1287
The text was updated successfully, but these errors were encountered: