Skip to content

fix: backport 401 stream-backed body fix to v7.x#5006

Merged
mcollina merged 1 commit intov7.xfrom
backport-4941-to-v7.x
Apr 10, 2026
Merged

fix: backport 401 stream-backed body fix to v7.x#5006
mcollina merged 1 commit intov7.xfrom
backport-4941-to-v7.x

Conversation

@mcollina
Copy link
Copy Markdown
Member

@mcollina mcollina commented Apr 9, 2026

Summary

Backport #4941 to v7.x.

This fixes the 401/auth retry regression for stream-backed request bodies introduced by #4747 in v7.19.0.

Changes

Validation

  • ./node_modules/.bin/borp -p "test/fetch/401-statuscode-no-infinite-loop.js"
  • all 3 tests passed

Fixes #5004

* fix: avoid 401 failures for stream-backed request bodies

- Properly implement isTraversableNavigable() to return false in Node.js
- Return 401 response directly for stream-backed bodies instead of throwing network error
- Aligns with Fetch spec discussion in whatwg/fetch#1132
- Add regression tests for PUT with ReadableStream and POST with JSON body

* fix: preserve 401 auth retries for URL credentials

(cherry picked from commit 4f4bf4f)
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina mcollina requested a review from KhafraDev April 9, 2026 08:13
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.15789% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.85%. Comparing base (c661067) to head (b11af4a).

Files with missing lines Patch % Lines
lib/web/fetch/index.js 53.33% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             v7.x    #5006      +/-   ##
==========================================
- Coverage   92.92%   92.85%   -0.08%     
==========================================
  Files         112      112              
  Lines       35725    35740      +15     
==========================================
- Hits        33199    33185      -14     
- Misses       2526     2555      +29     

☔ 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.

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.

2 participants