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

Node17 and Node18: Unable to parse stubbed response bodies from the mws rest.post #1349

Closed
4 tasks done
rosatolen opened this issue Jul 22, 2022 · 4 comments
Closed
4 tasks done
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node

Comments

@rosatolen
Copy link

Prerequisites

Environment check

  • I'm using the latest msw version
  • I'm using Node.js version 14 or higher

Node.js version

v18.6.0 and v17.9.1

Reproduction repository

https://github.com/rosatolen/msw-stub-post-bug-node17-node18

Reproduction steps

All steps are in the readme of the provided repository but they are provided here again:

  1. Ensure you are using node18 or node17. An .nvmrc file has been provided for ease of use.
  2. Run yarn install
  3. Run yarn test

Current behavior

When stubbing this post request response with msw, the response body causes the production code to hang while parsing it here. On the other hand, if I stub a get request response instead, I do not see the same issue.

Expected behavior

Parsing the response body stubbed by an msw rest.post should not cause my code to hang. The response body provided by the msw rest.post seems to be malformed in some way. The rest.post functionality should match the existing working functionality in rest.get.

@rosatolen rosatolen added bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node labels Jul 22, 2022
@rosatolen rosatolen changed the title Node18: Unable to parse stubbed response bodies from the mws rest.post Node17 and Node18: Unable to parse stubbed response bodies from the mws rest.post Jul 22, 2022
@nathanhannig
Copy link

My requests were also hanging, but I was on Node 16.10.0
#1327

@rosatolen
Copy link
Author

@nathanhannig The version of node16 where I don't see issues is 16.16.0. Not sure if that will help

@ddolcimascolo
Copy link

Node 16.13.0 here, reproduction repo is in #1327

@kettanaito
Copy link
Member

Hey, folks. Thanks for raising this.

We've addressed this issue in the latest next release tag. Please upgrade to npm i msw@next and read #1464 since it's a release candidate for 2.x and is a breaking change.

Working with request and response bodies is done using Fetch API primitives like Request and Response and works without issues. There's no intention to address this in the 1.x version of the library. Thank you for understanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node
Projects
None yet
Development

No branches or pull requests

4 participants