Skip to content

fix: reject unsupported FormData request bodies - #5913

Merged
mcollina merged 1 commit into
mainfrom
fix-5520-formdata-hang
Oct 14, 2026
Merged

mcollina merged 1 commit into
mainfrom
fix-5520-formdata-hang

Conversation

@mcollina

Copy link
Copy Markdown
Member

This relates to...

Fixes #5520.

Rationale

The low-level request path accepted structurally FormData-like bodies, while the multipart serializer only supports FormData created by the current undici package instance. A FormData from Node.js or another undici copy therefore reached body extraction but produced a stream that never emitted, closed, or errored, leaving the request pending indefinitely.

Reject unsupported FormData bodies during request validation, before a connection is opened. This keeps the request validator aligned with the serializer without broadening fetch's FormData compatibility rules.

Changes

  • validate FormData-like request bodies against the current undici package's FormData brand
  • reject unsupported bodies with InvalidArgumentError before connection setup
  • add regression coverage for Node.js's built-in FormData and a structurally FormData-like object
  • document the FormData provenance requirement for network clients

Features

N/A

Bug Fixes

  • prevent request() from hanging when passed FormData from another implementation

Breaking Changes and Deprecations

FormData from another implementation now rejects immediately. On affected v7 and v8 releases these bodies already failed or hung instead of completing successfully.

Status

Validation:

  • npm run test:unit
  • npx borp -p "test/client-request.js"
  • npx borp -p "test/http2-body.js"
  • npm run lint -- --no-cache
  • git diff --check

Signed-off-by: Matteo Collina <hello@matteocollina.com>
@codecov-commenter

codecov-commenter commented Sep 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.05%. Comparing base (7bc9dd6) to head (5cec4a1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5913      +/-   ##
==========================================
+ Coverage   94.04%   94.05%   +0.01%     
==========================================
  Files         110      110              
  Lines       40252    40267      +15     
==========================================
+ Hits        37856    37875      +19     
+ Misses       2396     2392       -4     

☔ View full report in Codecov by Harness.
📢 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.

@mcollina
mcollina merged commit f8c9be4 into main Oct 14, 2026
62 of 67 checks passed
@mcollina
mcollina deleted the fix-5520-formdata-hang branch October 14, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants