Skip to content

client-ofetch: no way to forward extra fetch options (allowlist in buildOfetchOptions) #4228

Description

@maxmaxme

Description

buildOfetchOptions (in client-ofetch/bundle/utils.ts) builds the object passed to $ofetch.raw() from a fixed allowlist — it names each option and drops the rest (no ...opts spread). RequestOptions and the plugin config (only throwOnError) offer no escape hatch either.

So there's no supported way to forward an option the template doesn't list:

  • Standard RequestInit fields ofetch supports (keepalive, mode, integrity, priority, …) get silently dropped.
  • Custom options for a swapped-in fetch (e.g. onUploadProgress for an XHR-based fetch) can't reach it at all.

The only workaround today is string-patching the generated utils.gen.ts / types.gen.ts, which is brittle.

Possible fixes (any one works):

  1. Spread standard RequestInit fields in buildOfetchOptions.
  2. Plugin config allowlist, e.g. forwardOptions: ['keepalive', 'onUploadProgress'].
  3. A fetchOptions passthrough on RequestOptions, merged verbatim into the $ofetch.raw() call.

Env: @hey-api/openapi-ts 0.99.0, @hey-api/client-ofetch, ofetch 2.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions