-
-
Notifications
You must be signed in to change notification settings - Fork 334
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
ky response is an empty string sometimes #563
Comments
I have this problem too. About 1 in 6 requests returns an empty response body in Bun (no problem in Node.js). If I add the following line in the let response = await ky._fetch();
// This prints an empty body in about 1 in 6 requests
response.clone().blob().then(blob => blob.text()).then( str => console.log("Blob for main request:", str));
// This always prints a body
fetch(this.request.clone(), {}).then( res => res.blob()).then(blob => blob.text()).then( str => console.log("Blob for cloned request:", str));
|
Got the same problem recently. In my case adding double # ❌ before
const userDetails = await client.get(`users/${id}`).json();
# ✅ after
const userDetails = await (await client.get(`users/${id}`)).json(); Really don't know why that helps, but after this change I've never experienced any problems. I'm also using |
fixed an issue that would cause ky to not parse json correctly. Fixed according to this issue: sindresorhus/ky#563 (comment)
Bun 1.0.29 (a146856d)
.text() or .json() works on a normal development environment (
bun i
), but does not (sometimes) on my production environment (without ky devDependencies,bun i -p
, while simple fetch() does).Response
Empty string when doing .json() or .text()
Posibly related to #490, but instead of request, response.
The text was updated successfully, but these errors were encountered: