Closed ailandini-accenture closed 1 month ago
Hi, @ailandini-accenture. Thanks for reporting this!
Please, could you provide a minimal reproduction repo for this? I have a bunch of similar scenarios passing in tests, so yours has to do something differently. Once you do, I'd be glad to look into this! Thanks.
@kettanaito working through it in the sandbox we realized the issue was on our side, apologies for the inconvenience!
No worries! Glad you've figured it out.
Prerequisites
Environment check
msw
versionNode.js version
v20.17.0
Reproduction repository
cloning a repo should not be required for this. But if its a necessity I'll do it.
Reproduction steps
Adapt a request handler anywhere in your app akin to the following:
This follows the documentation here
We are using vitest and our request library is react-query on top of fetch. We identified the issue was introduced in 2.4.4, but it persists in 2.4.9
Current behavior
Doing so at this level causes a Maximum call stack size exceeded error and immediate failures to any vitest test that fires off the intercepted request.
On a side note, we have a builder function which collects the request and serves it to the test later. IE:
Doing this returns an error because its trying to serialize the literal string "[object ReadableStream]" instead of the ReadableStream object
No issue in 2.4.3, and the issue is not resolved in latest (2.4.9).
I assume this must have something to do with changes in
mswjs/interceptors
. But as stated, in latest 0.35.8 this is not resolved.Expected behavior
Executing
await request.json()
should return the request payload, as it did in 2.4.3.