mswjs / msw

Industry standard API mocking for JavaScript.
https://mswjs.io
MIT License
15.97k stars 519 forks source link

XMLHttpRequest FormData / File upload never resolves #2326

Open ondrejsevcik opened 4 weeks ago

ondrejsevcik commented 4 weeks ago

Prerequisites

Environment check

Node.js version

v20.14.0

Reproduction repository

https://github.com/ondrejsevcik/msw-xhr-upload-issues

Reproduction steps

The reproduction repository contains two tests. One is firing an XHR request, and the other one is firing an XHR request with a FormData body.

If you use v2.4.3, the tests will pass. When using version 2.4.4+ it fails.

  1. npm install
  2. npm run test

Current behavior

The XHR request with FormData never resolves. This has worked fine previously, but since version 2.4.4, it does not work anymore.

Expected behavior

It is possible to upload file / FormData with msw using XMLHttpRequest.

kibertoad commented 4 weeks ago

@kettanaito Most likely related to this change: Adopts a new, Socket-based request interception algorithm.

roastnewt commented 3 weeks ago

I am encountering the same issue

LarsJK commented 1 week ago

I am also encountering this, but only on linux. On my Mac it works fine. What OS are you using?

roastnewt commented 1 week ago

Windows. And also in our Ubuntu build/test pipeline

RabbitShare commented 1 week ago

Same issue on Mac and Debian. Node v22.11.0

RabbitShare commented 1 week ago

Also example from documentation not working https://mswjs.io/docs/recipes/file-uploads/

veekeys commented 1 day ago

Getting same only on Linux (windows and mac work fine). Has there been any work started on this?

sayedMurtadha commented 20 hours ago

I had a similar issue and it worked only on Node V18. I tried with V20, V21, and V22, all of them failed the tests.