undici icon indicating copy to clipboard operation
undici copied to clipboard

Awaiting response.json() hangs on an aborted request.

Open andreas-karlsson opened this issue 6 months ago • 1 comments

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

andreas-karlsson avatar May 20 '25 07:05 andreas-karlsson

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.

mcollina avatar May 20 '25 10:05 mcollina