fix default Supabase auth fetch boundary - #25
Merged
Conversation
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.
Summary
globalThis.fetch.config.fetchas the stable captured implementation.PKCE through the same corrected default fetch boundary.
Regression Proof
Phase 3 changed the default fetch implementation from a wrapper to a captured raw function:
That captured function is later invoked as
normalizedConfig.fetch(...), which can change thefetch receiver. The new receiver-sensitive regression test installs
globalThis.fetchbeforeadapter creation, does not replace it afterward, and requires the fetch receiver to remain
globalThis.Against the old Phase 3 implementation, the new test failed with:
error: expect(received).toMatchObject(expected) Received: { "ok": false, "error": { "cause": [TypeError: incorrect fetch receiver], "code": "network_error", "message": "Unable to reach Supabase Auth." } }With the restored wrapper:
the same test passes:
The earlier runtime-replacement test still proves late-bound default fetch behavior, but the
receiver-sensitive test covers the production-like initialization timing where
globalThis.fetchis installed before the generated auth adapter is imported.
Validation
bun run buildbun run testbun run typecheckbun run lintbun run format:checkbun run knipbun run docsnpm --cache /private/tmp/supabase-auth-npm-cache pack --dry-run