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
We noticed that AbortSignal.timeout() stopped working in our library with longer timeouts (in our case around 9s). Debugging showed that cloned (or constructor copied) requests won't respect an abort signal if GC has happened in between.
Reproducible By
Run with node --expose-gc
import{createServer}from'node:http';createServer(()=>{// server that just hangs}).listen(3000);constac=newAbortController();letreq=newRequest('http://localhost:3000',{signal: ac.signal,});// cloned or copied requests (req = new Request(req)) breaks abort after gcreq=req.clone();setTimeout(()=>{// comment out the gc to make abort workglobal.gc();ac.abort();console.log('aborted, expecting immediate exception from fetch...');});awaitfetch(req);
Commenting out the cloning and/or the gc will make the code work as expected, i.e. the fetch call rejecting after abort.
Expected Behavior
A cloned request should respect it's abort signal even after a long time (or garbage collection).
Debugging found that the difference before/after gc is that the "dependentControllerMap" entry for the signal is missing here
This looks familiar to another issue with fetch/signals caused by the AbortSignal implementation in node core but I couldn't find the issue. Should this be posted in node core instead? Is there anything we can do to fix this in undici?
@KhafraDev I haven't managed to reproduce without Request involved. Also holding on strongly to the original request doesn't help. To me it seems odd that this could be a pure AbortSignal problem? Ah, or maybe you're saying that there can be a bug in the internal api of AbortSignal (like dependentControllerMap), but undici is using the api correctly..
Bug Description
We noticed that
AbortSignal.timeout()
stopped working in our library with longer timeouts (in our case around 9s). Debugging showed that cloned (or constructor copied) requests won't respect an abort signal if GC has happened in between.Reproducible By
Run with
node --expose-gc
Commenting out the cloning and/or the gc will make the code work as expected, i.e. the fetch call rejecting after abort.
Expected Behavior
A cloned request should respect it's abort signal even after a long time (or garbage collection).
Environment
macOS 15.3.1 (arm64), Node v23.4.0, v22.14.0, v20.18.0
Additional context
Debugging found that the difference before/after gc is that the "dependentControllerMap" entry for the signal is missing here
The text was updated successfully, but these errors were encountered: