bun
bun copied to clipboard
`fetch` cant handle `gzip` compressed data
Version
0.1.4
Platform
Microsoft Windows NT 10.0.25151.0 x64
What steps will reproduce the bug?
async function getInfo(rId) {
var res = await fetch(`https://users.roblox.com/v1/users/${rId}`).catch(err => console.log(err));
var data = res.data;
return data;
}
var rId = 520887847;
console.log(getInfo(rId));
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
Getting the json response I guess :-D
What do you see instead?
Zlib error error: fetch() failed – ZlibError url: "https://users.roblox.com/v1/users/520887847"
Additional information
Tested by discord users: Magic (338164255549423620)
Ubuntu WSL: Linux momtamer69 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Powershell: Microsoft Windows NT 10.0.22000.0 x64
Kapsonfire (233904020509556736)
Debian WSL: Linux KAPS-PC 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 GNU/Linux
Microsoft Windows NT 10.0.25151.0 x64
What happens if you remove Accept-Encoding? Bun handles compression automatically, but it's possible this breaks if Accept-Encoding is explicitly passed as explicitly passing it lacks test coverage
you are not allowed to change Accept-Encoding in fetch api
sorry didnt remove it from my code on top. changing headers for accept-encoding does not work. even if you drop it, it doesnt work. it was just a test to evade this error
//edit: removed it from code
Tested, I can reproduced it on:
Darwin mac 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:29 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T8101 arm64
na its not about deflate @Jarred-Sumner its gzip the server sends
fwiw i was able to get a request working from the same zlib error by adding Accept-Encoding: gzip to the headers
const getTreeRes = await fetch(
`https://endpoint.here`,
{
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Accept-Encoding': 'gzip',
},
},
)
We need to fix this issue, and will. A temporary workaround is to provide an Accept-Encoding header.
const response = await fetch("https://example.com/", {
headers: {
"Accept-Encoding": "identity",
}
});
Should be fixed in #1510
Seems like a common HTTP server library is just broken when deflate is preferred over gzip