feat(openapi-ts): add typed FetchError for fetch client#3844
feat(openapi-ts): add typed FetchError for fetch client#3844Krisztiaan wants to merge 1 commit intohey-api:mainfrom
Conversation
|
|
🦋 Changeset detectedLatest commit: 2a3e2d1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@Krisztiaan is attempting to deploy a commit to the Hey API Team on Vercel. A member of the Team first needs to authorize it. |
|
TL;DR — Introduces an opt-in Key changes
Summary | 594 files | 1 commit | base:
|
There was a problem hiding this comment.
Important
Missing changeset and one minor message formatting nit. Overall the implementation is solid — the class design, interceptor passthrough, double-wrap guard, and TanStack Query type integration all look correct.
Task list (5/5 completed)
- Checkout PR and read the diff
- Identify major areas of change and high-risk sections
- Deep review of implementation changes
- Impact analysis - check for breaking changes
- Self-critique and submit review
| return 'Request failed'; | ||
| }; | ||
|
|
||
| export class FetchError<TError = unknown> extends Error { |
There was a problem hiding this comment.
This is a breaking change for throwOnError: true users — caught values change from raw error bodies to FetchError instances. A changeset is required for the release pipeline. Given it changes what throw produces, this likely warrants a major version bump for @hey-api/client-fetch (or at minimum a minor with clear migration notes).
There was a problem hiding this comment.
Verified against the current implementation: this is now opt-in via throwOnErrorStyle: 'wrapper', so the default throwOnError: true behavior still throws the raw backend body. Added .changeset/fetch-error-wrapper.md as a minor release note for the new opt-in FetchError API.
3e444c9 to
9dac82f
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3844 +/- ##
==========================================
+ Coverage 39.58% 39.65% +0.07%
==========================================
Files 532 533 +1
Lines 19580 19616 +36
Branches 5829 5842 +13
==========================================
+ Hits 7751 7779 +28
- Misses 9581 9589 +8
Partials 2248 2248
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@hey-api/codegen-core
@hey-api/json-schema-ref-parser
@hey-api/nuxt
@hey-api/openapi-ts
@hey-api/shared
@hey-api/spec-types
@hey-api/types
@hey-api/vite-plugin
commit: |
9dac82f to
4932339
Compare
|
Acknowledged the author's fix for the HTTP/2 |
|
Review submitted. Leaping into action... |
4932339 to
2a3e2d1
Compare

Summary
FetchError<TError>wrapper for@hey-api/client-fetchthrowOnErrorStyle: 'wrapper'forthrowOnErrorfailuresFetchError.errorwhile exposingrequest,response,status,statusText, andheadersFetchError<OperationError>only when the fetch client plugin opts intothrowOnErrorStyle: 'wrapper'Compatibility
throwOnError: falsekeeps the existing returned result shape: typed error body plus request/response fields.throwOnError: truestill throws the raw parsed backend error body by default.@hey-api/client-fetchwiththrowOnErrorStyle: 'wrapper'; then thrown errors and generated TanStack error generics useFetchError<OperationError>.FetchError, the client rethrows it without double wrapping.response,status,statusText, andheaderscan be undefined when no HTTP response exists.Release
.changeset/fetch-error-wrapper.mdas a minor changeset for@hey-api/openapi-ts.Verification
pnpm --filter @hey-api/openapi-ts buildpnpm exec vitest run --config vitest.local.config.mts src/plugins/@hey-api/client-fetch/__tests__/client.test.ts(package-local temporary config, removed)pnpm exec vitest run --config vitest.local-no-examples.config.mts --project @test/openapi-ts --project @test/openapi-ts-nestjs-v11 --project @test/openapi-ts-orpc-v1 --project @test/openapi-ts-sdks --project @test/openapi-ts-valibot-v1 --project @test/openapi-ts-tanstack-query-v5 --project @test/openapi-ts-zod-v3 --project @test/openapi-ts-zod-v4 --update(temporary config, removed)pnpm examples:checkpnpm --filter @hey-api/openapi-ts typecheckpnpm --filter @test/openapi-ts-tanstack-query-v5 typecheckNote: local root
vitest --project ...and fullpnpm buildcan fail in this environment before reaching the requested project because Vue devtools callslocalStorage.getItemwhile loading example configs. GitHub CI is authoritative for those full-matrix checks and is passing except for Vercel authorization.