fix(client-fetch): [BUG] cancel inferred stream bodies#3831
fix(client-fetch): [BUG] cancel inferred stream bodies#3831Stono wants to merge 2 commits intohey-api:mainfrom
Conversation
|
|
|
@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