-
-
Notifications
You must be signed in to change notification settings - Fork 715
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
When sending a FormData as body with request or stream, the request fails if redirected with the following TypeError: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Array
Reproducible By
In the following example a POST request is made to http://github.com, which automatically redirects to https://github.com. The issue is reproducible with any other url that triggers a redirect.
import { FormData, request } from "undici";
const body = new FormData();
body.append("hello", "world");
await request("http://github.com", {
body,
method: "POST",
maxRedirections: 1,
});Expected Behavior
Not sure about the specs but the body should be either redirected or discarded based on the redirect type, without any errors.
Logs & Screenshots
node:buffer:776
throw new ERR_INVALID_ARG_TYPE(
^
TypeError [ERR_INVALID_ARG_TYPE]: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Array
at Function.byteLength (node:buffer:776:11)
at AsyncWriter.write (D:\test\node_modules\undici\lib\dispatcher\client-h1.js:1259:24)
at writeIterable (D:\test\node_modules\undici\lib\dispatcher\client-h1.js:1219:19) {
code: 'ERR_INVALID_ARG_TYPE'
}Environment
Windows 11 Home, Node v22.11.0
Additional context
Tested with various redirect urls and the issue is always reproducible
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working