openapi-ts / openapi-typescript

Generate TypeScript types from OpenAPI 3 specs
https://openapi-ts.dev
MIT License
5.57k stars 454 forks source link

Headers lost in fetch request when using BUN #1736

Open ryou90 opened 2 months ago

ryou90 commented 2 months ago

Description

To make Openapi-Fetch more compatible with Bun, the fetch call should be modified. The problem is that Bun removes all header information within the request object. To avoid this problem, the headers should be passed as extra parameters and not within the request object.

See also here: https://github.com/oven-sh/bun/issues/9846

Current behavior :

let response = await fetch(request);

Suggestion:

let response = await fetch(request, {headers : headers});

Reproduction Create simple Get request with header informations.

Expected result

Headers send with request

marcomuser commented 2 months ago

Sounds like a bug in bun not openapi-fetch? I would expect the runtime to conform to the spec instead of having libraries patch all sort of runtime bugs. Especially now since there seems to be a new js runtime every week.

stevegoossens commented 1 month ago

The Bun bug/issue is now closed, so perhaps this is now no longer a problem (when using a sufficiently recent version of Bun)