undici
undici copied to clipboard
Awaiting response.json() hangs on an aborted request.
Bug Description
Awaiting response.json() hangs on an aborted request.
Reproducible By
This happens in our production environment. The only way we've managed to reproduce it locally is by running a fetch client in a resource constrained docker container (1 cpu) and then also simulating additional load in the process by for instance calculating primes.
Expected Behavior
response.json() should reject if the request is aborted while the response stream is open.
Environment
Reproduced on dockerized linux for at least node versions 20.18.0 and 23.9.0
Additional context
Through debugging we've seen that responses that hang go through this code path: https://github.com/nodejs/undici/blob/95fd9d3feebcdede11a4e6b66f57aac34abf482f/lib/web/fetch/index.js#L354
Thanks for reporting!
Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.