fix(client-fetch): [BUG] cancel inferred stream bodies#3831
Conversation
chore(deps): update dependency @orpc/contract to v1.13.13
chore(deps): update dependency @types/bun to v1.3.11
fix: bump node to v22
chore(deps): update dependency jsdom to v29
chore(deps): update dependency @types/eslint to v9.6.1
chore(deps): update dependency @types/jasmine to v5.1.15
chore(deps): update dependency @types/node to v24.12.0
chore(deps): update dependency @types/jasmine to v6
chore(deps): update dependency @types/jsdom to v28
chore(deps): update dependency globals to v17
chore(deps): update dependency npm-run-all2 to v8
…onorepo chore(deps): update dependency jasmine-core to v6
fix(deps): update dependency c12 to v3.3.4
perf(hey-api#3819/hey-api#3030): 30x speed up
…rrors-zod-schemas fix(zod): fall back to `z.union()` when discriminated union members are `ZodIntersection`
…tion has no required params
Move options to the last parameter position in both setQueryData and useSetQueryData so it can be properly optional when the operation has no required params. The previous approach placed options? in the middle with a required param after it, which is invalid TypeScript. Also removes duplicate isRequiredOptions declarations introduced in a prior commit.
fix(client-core): resolve runtimeConfigPath relative to generated output
…t/tanstack-set-query-data
…ery-data feat(@tanstack/query): generate type-safe setQueryData helpers
|
|
|
@Stono 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 — When Key changes
Summary | 2 files | 2 commits | base: Cancel inferred stream bodies to prevent resource leaks
|
There was a problem hiding this comment.
Important
client-next and client-ky have the same case 'stream': pattern with getParseAs returning 'stream' for null Content-Type — they are susceptible to the same dangling-stream issue. Consider applying the same fix there (separate PR is fine).
Good fix overall. The opts.parseAs === 'auto' guard correctly distinguishes between inferred and explicit stream mode, and the response.body?.cancel() call properly releases the underlying connection. Two minor items below.
Task list (4/4 completed)
- Read the PR diff and understand the changes
- Read the PR description and linked issue for context
- Investigate the changed source file in full context
- Self-critique and submit review

Hey,
So I wrote a new app recently that pings a heartbeat every 5s, the endpoint is a 204/no-content, and generated the client for that app using the latest hey-api library.
The app was dying mysterious after a while, and then i remembered a similar issue we had ages ago where unconsumed fetch bodies eventually killed the app.
Looking into the code, it looks to be the same problem here, so this PR adds canceling of response bodies where no response content is expected.
Whats Changed
Updated the client-fetch runtime to cancel inferred stream bodies in auto mode:
Behaviour in explicit stream mode remains unchanged:
Why