Skip to content
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

Open
tnfAngel opened this issue Mar 3, 2024 · 1 comment
Open

ky response is an empty string sometimes #563

tnfAngel opened this issue Mar 3, 2024 · 1 comment

Comments

@tnfAngel
Copy link

tnfAngel commented Mar 3, 2024

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
img

Empty string when doing .json() or .text()
img

Posibly related to #490, but instead of request, response.

@vibl
Copy link

vibl commented Mar 15, 2024

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 function_() function (line 19), I always get a response body with the cloned request, even when the main request response doesn't return a body.

        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));
       

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants