fix: return AbortError instead of TypeError when consuming aborted cloned response#4801
fix: return AbortError instead of TypeError when consuming aborted cloned response#4801
Conversation
53fe150 to
ec025fe
Compare
…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>
ec025fe to
f678a03
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
KhafraDev
left a comment
There was a problem hiding this comment.
none of the code here is correct
|
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. |
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
consumeBody()response.abortedflag inabortFetch()to properly track abort stateTest
Includes test from #4800 (thanks @afoures)
Fixes: #4799
Refs: #4800