Skip to content

fix: avoid reusing disturbed request bodies#2515

Draft
nandan-bhat wants to merge 1 commit intomainfrom
fix/my-account-with-nodejs
Draft

fix: avoid reusing disturbed request bodies#2515
nandan-bhat wants to merge 1 commit intomainfrom
fix/my-account-with-nodejs

Conversation

@nandan-bhat
Copy link
Contributor

Changes

  • Make toNextRequest clone Requests when possible and skip attaching bodies that are already used/locked.
  • Prevent “Response body object should not be disturbed or locked” errors in proxy/middleware flows.
  • Add a regression test for consumed-body inputs.

Why

  • Some proxy paths (e.g., /me/*) buffer the request body before other SDK helpers run. Re-wrapping the same Request into a NextRequest after the body is consumed throws in Node runtime.
  • The new logic preserves normal behavior for fresh requests while safely handling already-used bodies.

@codecov-commenter
Copy link

codecov-commenter commented Feb 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.27%. Comparing base (7a15b30) to head (cefe1c4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2515      +/-   ##
==========================================
+ Coverage   91.22%   91.27%   +0.05%     
==========================================
  Files          39       39              
  Lines        4705     4735      +30     
  Branches      987     1001      +14     
==========================================
+ Hits         4292     4322      +30     
  Misses        407      407              
  Partials        6        6              

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

@nandan-bhat nandan-bhat force-pushed the fix/my-account-with-nodejs branch from b4eedf3 to 55fbdb9 Compare February 2, 2026 12:50
@nandan-bhat nandan-bhat force-pushed the fix/my-account-with-nodejs branch from 55fbdb9 to cefe1c4 Compare February 2, 2026 13:05
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

Comments