Closed Maxim-Mazurok closed 1 year ago
I think your solution is correct.
But the identify
is depending on the server implementation. (The server still can return compressed response if specified the identify
.
Could you test with "Accept-Encoding": "gzip"
?
If it worked, I think it's better solution because gzip
is very popular encoding.
Or, Could you know the free, open and public API that able to reproduce this problem?
gzip
doesn't seem to work either, giving incorrect header check
, even though API seems to support it and snapshot looks fine.
FAIL util.spec.ts > getHoneyProductHistory > works
FetchError: Invalid response body while trying to fetch https://d.joinhoney.com/v3?operationName=web_getProductPriceHistory&variables=%7B%22productId%22%3A%227613592105936880680_c9cfbae01a9af7d396c1f977224a4b8a_c9cfbae01a9af7d396c1f977224a4b8a%22%2C%22timeframe%22%3A30%7D:
incorrect header check
❯ consumeBody node_modules/node-fetch/src/body.js:234:60
❯ Response.text node_modules/node-fetch/src/body.js:158:18
❯ Response.json node_modules/node-fetch/src/body.js:148:16
❯ Module.getHoneyProductHistory util.ts:45:19
43| );
44|
45| const result = (await response.json()) as GetProductPriceHistoryAPI;
| ^
46|
47| return result;
❯ util.spec.ts:36:20
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯Serialized Error: {
"code": "Z_DATA_ERROR",
"errno": "Z_DATA_ERROR",
"erroredSysCall": undefined,
}
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
I'm not sure if that API is public, but it works without any special headers/cookies so one could use it for testing compression:
https://d.joinhoney.com/v3?operationName=web_getProductPriceHistory&variables=%7B%22productId%22%3A%227613592105936880680_c9cfbae01a9af7d396c1f977224a4b8a_c9cfbae01a9af7d396c1f977224a4b8a%22%2C%22timeframe%22%3A30%7D
Hm... Unfortunately, I can't reproduce the provided API with adding it as a new test-case.
My environment are
@Maxim-Mazurok I think the v0.2.0
solves this problem. Could you try it?
I've re-published the v0.3.0
.
I've tried v1.1.0
and it works, thank you!
Hello, first of all, thank you for creating this, I'm using it to integrate with 3rd-party API, and it helps me to ensure that my mocks/snapshots will stay up to date with the actual 3rd-party API that I don't control.
The issue I'm having is that when the actual server replies with compressed response (brotli in my case) - it looks like node-fetch tries to decompress the response, and fails because it's already a plain text (as replaced/transformed by this plugin).
This is the error message I'm getting:
I have tried to remove some headers to help node-fetch understand that it's plain text:
But it didn't help.
For now, I'll be using this workaround to disable compression for requests:
Let me know what you think, happy to help with this!