Repository navigation
fix: strip client selector from request options (breaks Deno / edge runtimes) - #9
Merged
Merged
Conversation
…untimes) _bind injects the per-instance client into operation options under the `client` key, and @hey-api/client-fetch spreads the whole options object into the fetch RequestInit. Deno defines its own `client` RequestInit option (a Deno.HttpClient) and validates it, so new Request(...) threw and every SDK call failed on Deno, Deno Deploy, and Supabase Edge Functions. Node's undici silently ignores the stray key, which is why the suite never caught it. Operations now dispatch through a wrapper client whose HTTP methods strip the selector before hey-api builds the request; the real client (config, interceptors) is untouched. Applied in both src/client.ts and the generate-client.ts template so regeneration preserves the fix. Workaround for hey-api/hey-api#4177 — remove once the upstream fix ships and the dependency can be upgraded. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Deno and other WinterCG runtimes validate RequestInit strictly, so bugs that leak internal SDK fields into new Request(...) are invisible to the Node-only suite but break every call on Deno Deploy / Supabase Edge Functions. The new CI job builds the bundle and runs a real SDK call under Deno against a stubbed fetch (no network, no credentials); the tests fail on the pre-fix build and pass with the fix. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Ooscaar
added a commit
that referenced
this pull request
Aug 10, 2026
Sync main with the manually dispatched publish of 0.2.544 (Deno / edge-runtime fix, #9) so the next auto-release bumps cleanly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Every SDK call throws on Deno-based runtimes (Supabase Edge Functions, Deno Deploy) before any network I/O:
_bindinjects the per-instance client into each operation's options under theclientkey, and@hey-api/client-fetchspreads that whole options object into the fetchRequestInit. Node's undici silently ignores the unknown field (which is why the Node-only suite never caught it), but Deno defines its ownclientinit option (aDeno.HttpClient) and validates it, sonew Request(...)throws. The SDK is effectively unusable on those runtimes.This was reported with an excellent diagnosis in #8 (thanks @henrikra!). This PR lands the same fix with two changes:
src/client.tsis generated byscripts/generate-client.ts, so a fix applied only toclient.ts(as in fix: stop leaking the client selector into RequestInit (breaks Deno / edge runtimes) #8) would be silently wiped on the nextnpm run generate. This PR applies the fix in the generator template as well._bindinjects a thin wrapper that leaves the third-party object untouched.Upstream tracking: this is a known hey-api bug (hey-api/hey-api#4177) with an unmerged fix (hey-api/hey-api#4178). No released version of
@hey-api/client-fetch(deprecated at 0.13.1) or the bundled-client architecture fixes it, so a downstream workaround is currently the only option. ATODOmarks it for removal once upstream ships.What
_stripClientSelector()+_dispatchClienttosrc/client.ts: a wrapper around the per-instance client that delegates everything to it but strips theclientselector from request options before hey-api builds theRequest;_bindnow injects the wrapper. Config and interceptors stay on the real client, per-instance isolation is unchanged.scripts/generate-client.tsso regeneration preserves the fix.tests/request-init.test.ts: captures theRequestInitatnew Requesttime (the only way to observe this on Node), asserts the selector never leaks, and verifies auth-header routing and two-instance isolation. Fails onmain, passes with this change.Verification:
tsc --noEmitandeslintclean.fetch: themainbuild reproduces the exact TypeError; this build succeeds with the auth header intact.accounts.listAccountsandprofiles.listProfilesreturn 200 with byte-identical payloads.Closes #8 (supersedes it — see regeneration note above; happy to defer to it instead if preferred).
Follow-ups
fetch, as suggested in fix: stop leaking the client selector into RequestInit (breaks Deno / edge runtimes) #8 — the whole bug class is invisible to a Node-only matrix._stripClientSelector/_dispatchClient(marked with a TODO), and keep the regression test.openapi.yamlis stale relative to the committedsrc/client.ts(regenerating today would drop ~700 lines of operations) — refresh the spec before the nextnpm run generate.🤖 Generated with Claude Code