Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests not terminating after execution with msw when using FormData and Blob #2413

Closed
tokuhirom opened this issue Nov 8, 2023 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@tokuhirom
Copy link

tokuhirom commented Nov 8, 2023

Bug Description

I'm encountering an issue where the process does not terminate after running tests with msw when using FormData and Blob. Removing the line where the Blob is appended to the FormData allows the tests to terminate as expected.

Reproducible By

Below is a simplified test case to illustrate the issue:

https://github.com/tokuhirom/msw-formdata-issue

~/work/msw-formdata-issue/ npm test

> msw-formdata-issue@1.0.0 test
> mocha



  test
{}
    ✔ test


  1 passing (22ms)

When the above code is executed, the process does not terminate after running the test. However, if the line with formData.append(...) is commented out, the process terminates correctly. It seems that the use of FormData in combination with Blob in msw setup is causing some resources to not be released properly.

Expected Behavior

exit the process after running all tests.

Logs & Screenshots

Environment

Node.js 21.1.0

Additional context

At first, I noted this issue to msw repo, but msw author suggest to post this issue to undici.
ref. mswjs/msw#1843

@tokuhirom tokuhirom added the bug Something isn't working label Nov 8, 2023
tokuhirom added a commit to tokuhirom/line-bot-sdk-nodejs that referenced this issue Nov 8, 2023
@KhafraDev
Copy link
Member

since this is likely an issue in blob, you'll have to post it in the node repo, preferably with a reproduction that doesn't use third party dependencies.

@rbertucat
Copy link

rbertucat commented Nov 22, 2023

I have the same issue when passing whatever value to the FormData, not only a Blob, using the append method.

It seems to me that it comes from the clone() method of body:

function cloneBody (body) {

@kettanaito
Copy link
Contributor

I've reported what looks like a duplicate of this: nodejs/node#52167. Also includes a simple reproduction script without any third-parties. Cloning requests with FormData body hangs forever (given that form data is not empty). Hasn't tested with blobs.

@mcollina
Copy link
Member

This is fixed here.

@thaynarbo
Copy link

thaynarbo commented Sep 16, 2024

hello @mcollina, was this released?
on the browser the form data seems to work fine
image
but as soon as a grab request and try to get the information as formdata, it gives the following error. I'm using axios and vitest. When I logged the content type it prints: text/plain;charset=UTF-8, but I'm passing 'multipart/form-data' as you can see on the browser tab above.
Here is the error on console:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants