-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
fetch based library (ky), randomly returns empty string instead of actual body (json) #6969
Comments
Did you notice this after upgrading Bun recently? Or did you just run into this |
just run into this randomly |
@dimonnwc3 @Electroid #6468 fixes this whenver it gets merged, just confirmed its because ky uses |
The issue is a race condition whether the internal network process received the entire body payload before resolving the initial fetch promise, if yes the body is correctly copied and all is good, if data is still coming in the internal body state is locked leading to the clone just having a empty body. |
Experiencing this |
The pr would be ready for final review and merge(if it passes review) but the maintainers don't prioritize such bug fixes(api compliance) sadly over adding new features because its a "bigger change", so i cant give you a estimate. |
I am experiencing this bug because I was using Simplest way to trigger the bug as of Bun v1.0.25 (latest as of time of writing) const server = Bun.serve({
fetch: async (req) => {
console.log(await (await req.clone()).text()) // This is empty instead of containing the body text
console.log(await req.text()) // Contains the actual body, but now you can't call .text(), .json(), etc. again
},
}); This looks awfully similar to #913 which was apparently fixed, but does not seem to be. Is this actually a regression of that? Edit: Turns out this is the same underlying issue as #6348 actually |
Duplicate of #6348 |
(We fill fix this) |
What version of Bun is running?
1.0.10+d85bd49d8
What platform is your computer?
Darwin 23.1.0 arm64 arm
What steps can reproduce the bug?
run this code with
bun run
wait for 1 minute, it will print randomly "no data" into the console, meaning that some response bodies are empty string
What is the expected behavior?
I expect to get correct response every time I do request
What do you see instead?
I see empty string in response body
Additional information
same code is running in node v18.15.0 returning consistent results
The text was updated successfully, but these errors were encountered: