fix(sdk): don't expose SSE errors as iterator return types#3989
Conversation
|
|
|
@frastefanini is attempting to deploy a commit to the Hey API Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 2a458c3 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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3989 +/- ##
=======================================
Coverage 39.21% 39.21%
=======================================
Files 607 607
Lines 21468 21468
Branches 6345 6345
=======================================
Hits 8418 8418
Misses 10626 10626
Partials 2424 2424
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: |
There was a problem hiding this comment.
Reviewed changes — This PR fixes the SDK return type for SSE operations so endpoint error types are no longer threaded into ServerSentEventsResult's TReturn generic slot (the async generator return type). It is a follow-up to #3919, which fixed the generated client SseFn types but left the SDK return type builder emitting the old shape.
- Shorten SSE SDK return type —
Promise<ServerSentEventsResult<Responses, Errors | void, ThrowOnError>>is replaced byPromise<ServerSentEventsResult<Responses>>inoperationReturnType(). - Preserve call-site arity — The generated call expression still passes
<Responses, Errors, ThrowOnError>intoclient.sse.*for compatibility with the currentSseFngeneric arity. - Update snapshots — Covers main 3.1.x SSE fixtures (Angular, Axios, Fetch, Next.js, ofetch), TanStack Query SSE fixture, and SDK opencode fixtures (flat, grouped, export-all).
- Leave Nuxt unchanged — Nuxt's SSE shape differs (error flows through
RequestResult, notTReturn).
Kimi K2 | 𝕏
There was a problem hiding this comment.
Reviewed changes — This PR fixes the SDK return type for SSE operations so endpoint error types are no longer threaded into ServerSentEventsResult's TReturn generic slot (the async generator return type). It is a follow-up to #3919, which fixed the generated client SseFn types but left the SDK return type builder emitting the old shape.
- Shorten SSE SDK return type —
Promise<ServerSentEventsResult<Responses, Errors | void, ThrowOnError>>is replaced byPromise<ServerSentEventsResult<Responses>>inoperationReturnType(). - Preserve call-site arity — The generated call expression still passes
<Responses, Errors, ThrowOnError>intoclient.sse.*for compatibility with the currentSseFngeneric arity. - Update snapshots — Covers main 3.1.x SSE fixtures (Angular, Axios, Fetch, Next.js, ofetch), TanStack Query SSE fixture, and SDK opencode fixtures (flat, grouped, export-all).
- Leave Nuxt unchanged — Nuxt's SSE shape differs (error flows through
RequestResult, notTReturn).
Kimi K2 | 𝕏
mrlubos
left a comment
There was a problem hiding this comment.
This looks good, thank you @frastefanini!

Closes #3990
Summary
Follow-up to #3919.
#3919 correctly fixed generated client
SseFntypes so endpoint HTTP errors are no longer threaded intoServerSentEventsResult's second generic slot. That slot isAsyncGenerator'sTReturn, not an error channel.However, the SDK return type builder still emits the old SSE shape:
while generated clients now return:
This makes generated SDK functions fail TypeScript assignability checks for SSE endpoints with concrete error responses.
Change
For SSE operations, the SDK return annotation now mirrors the client result shape:
The generated call expression still passes
<Responses, Errors, ThrowOnError>intoclient.sse.*to preserve compatibility with the currentSseFngeneric arity introduced/preserved by #3919.Updated generated snapshots covering:
Nuxt is unchanged because its SSE type shape is different: it wraps
RequestResultinsideServerSentEventsResultrather than passing the HTTP error type asTReturn.Why
HTTP errors are not the async iterator completion value. They are handled by the initial request promise / SSE error hooks. The public SDK return type should therefore not expose endpoint error types through
ServerSentEventsResult'sTReturn.Test plan
pnpm vitest runacross@test/openapi-ts-sdks,@test/openapi-ts,@test/openapi-ts-tanstack-query-v5pnpm typecheckpnpm lint:fix