oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.13k stars 2.76k forks source link

bun doesn't work correctly with `ky` - a popular fetching library #11682

Open blitss opened 5 months ago

blitss commented 5 months ago

ky is a popular fetching library based on fetch which has over 10k stars on Github. It doesn't work nice with Bun and sometimes provides undefined instead of json output.

What version of Bun is running?

1.1.12+43f0913c3

What platform is your computer?

Darwin 23.5.0 arm64 arm

What steps can reproduce the bug?

create repro.ts file and run it:

import _ky from 'ky'

const ky = _ky.extend({
  "method": "GET",
})

while (true) {
  const fetched = await ky('https://jsonplaceholder.typicode.com/posts/1').json<any>()
  console.log(fetched.id)
}

What is the expected behavior?

Bun expected to output

1
1
1
1
1
1
1
1

Literally always one

What do you see instead?

It randomly provides undefined values, which doesn't happen with node

$ bun repro.ts
undefined
undefined
undefined
1
undefined
1
1
undefined
undefined
undefined
1
1
1
1
1
undefined
1
undefined
1
1
1
1
1
1

Additional information

No response

devunt commented 2 months ago

Related to #1381, #2477, #6348. Possible fix in #12473 is waiting for landing.

LucHermkens commented 1 month ago

Fixed in Bun v1.1.27