-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Labels
Description
Describe the bug
When using environment: "jsdom" in Vitest configuration, calling .formData() or .arrayBuffer() on a Request object causes the returned Promise to never resolve if the FormData contains a File or Blob object.
This problem started occurring from Vitest v4.0.7.
Reproduction
import { describe, test } from "vitest";
describe("FormData", () => {
test(".formData() with File", async () => {
const formData = new FormData();
formData.append("file", new File(["test"], "test.txt"), "test.txt");
const request = new Request("http://localhost/", {
method: "POST",
body: formData,
});
const promise = request.formData();
console.log(promise);
// The promise is never resolved
const requestFormData = await promise;
console.log(requestFormData);
});
test(".arrayBuffer() with File", async () => {
const formData = new FormData();
formData.append("file", new File(["test"], "test.txt"), "test.txt");
const request = new Request("http://localhost/", {
method: "POST",
body: formData,
});
const promise = request.arrayBuffer();
// The promise is never resolved
const requestArrayBuffer = await promise;
console.log(requestArrayBuffer);
});
});System Info
System:
OS: macOS 14.7.1
CPU: (14) arm64 Apple M3 Max
Memory: 43.05 MB / 36.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.11.0 - ~/.nodenv/versions/24.11.0/bin/node
npm: 11.6.1 - ~/.nodenv/versions/24.11.0/bin/npm
pnpm: 10.21.0 - ~/.nodenv/versions/24.11.0/bin/pnpm
Browsers:
Chrome: 142.0.7444.176
Firefox: 139.0.1
Safari: 18.0
npmPackages:
vitest: ^4.0.14 => 4.0.14Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.