Closed tim-coulter closed 3 months ago
Hi, @tim-coulter. Thanks for reporting this.
We are working on improving the handling of encoded response bodies in Node.js, and hope to merge the fix in the nearest future. One of such improvements is making Undici expose their encoding utilities (see https://github.com/nodejs/undici/pull/3423) and then forwarding that usage to Interceptors (see https://github.com/mswjs/interceptors/pull/604). Once these two are merged, MSW should handle compressed response bodies correctly in Node.js.
Prerequisites
Environment check
msw
versionNode.js version
v22.3.0
Reproduction repository
https://github.com/tim-coulter/msw-got-compression-example
Reproduction steps
npm i
npm run server
npm run test
Note that this is only reproducible with the following:
app.use(compression);
on the mock serverCurrent behavior
When the msw server has not started listening both the
got
andfetch
requests work as expected and return a response. When the mock server is started, however, only the fetch request returns a response but the request using got appears to hang (got works 2 is never seen).Expected behavior
As that request is not being intercepted by msw the behaviour should be exactly the same as before starting the server as after (the request made using got should not hang).