Skip to content

Conversation

@mcollina
Copy link
Member

@mcollina mcollina commented Feb 3, 2026

When a Response was cloned and the AbortController was aborted before consuming the body, consuming the body threw a TypeError ('Body is unusable') instead of the expected AbortError.

Changes

  • Check for aborted state before checking if body is unusable in consumeBody()
  • Set response.aborted flag in abortFetch() to properly track abort state

Test

Includes test from #4800 (thanks @afoures)

Fixes: #4799
Refs: #4800

@mcollina mcollina force-pushed the fix/4799-response-clone-abort branch from 53fe150 to ec025fe Compare February 3, 2026 07:56
…oned response

When a Response was cloned and the AbortController was aborted before consuming the body, consuming the body threw a TypeError (Body is unusable) instead of the expected AbortError.

Changes:

- Check for aborted state before checking if body is unusable in consumeBody()

- Set response.aborted flag in abortFetch() to properly track abort state

Fixes: #4799

Refs: #4800

Co-authored-by: Antoine Fourès <contact@afoures.com>
@mcollina mcollina force-pushed the fix/4799-response-clone-abort branch from ec025fe to f678a03 Compare February 3, 2026 08:08
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.25%. Comparing base (352c691) to head (f678a03).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4801      +/-   ##
==========================================
- Coverage   93.25%   93.25%   -0.01%     
==========================================
  Files         109      109              
  Lines       34024    34105      +81     
==========================================
+ Hits        31729    31803      +74     
- Misses       2295     2302       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@KhafraDev KhafraDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

none of the code here is correct

@KhafraDev
Copy link
Member

What I've noticed from using Claude on the code in undici: it sucks by default. I've found ways to improve on its output while also speeding up my process for bug fixing; have it fetch the spec in its entirety and then ask it to 1) do not edit existing comments under any circumstance, and 2) implement changes verbatim to the spec text. Without the spec text, it often does things like we see here where it adds a non-existent step 6 with a nonsensical change.

I usually end up doing all of the coding manually, using Claude to track down bugs, but then implementing the fix myself to ensure Claude doesn't muck it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cloning Response change default aborting behavior

3 participants