fix(ui): AuthProvider SSR crash with partial auth SDK (#2302)#2308
Merged
Conversation
AuthProvider accessed auth.signIn.url and auth.signUp.url during construction, before any isBrowser() guard. In the Rust V8 isolate, these SDK methods may be undefined, causing a TypeError crash that blocks SSR for all routes using AuthProvider. Use optional chaining with safe defaults (empty string for url, 'POST' for method) so construction succeeds even with a partial auth SDK. Closes #2302 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address review finding: signIn/signUp async bodies now check typeof auth.signIn === 'function' before calling, returning an error Result instead of crashing when the SDK method is undefined. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Apr 5, 2026
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
auth.signIn?.url ?? ''andauth.signUp?.url ?? ''preventTypeErrorwhen auth SDK methods are undefined in the Rust V8 isolatesignIn/signUpasync bodies checktypeof auth.signIn === 'function'and return an errorResultinstead of crashing when SDK methods are unavailablePublic API Changes
None. Internal defensive fix only —
AuthProviderprops anduseAuth()return type are unchanged.Related
Closes #2302
Files Changed
packages/ui/src/auth/auth-context.ts— optional chaining + runtime guardpackages/ui/src/auth/__tests__/auth-context.test.ts— 6 new testsTest plan
bun test src/auth/__tests__/auth-context.test.ts— 63/63 passtsc --noEmit— cleanoxlint— 0 errors (warnings are pre-existing)oxfmt --check— clean🤖 Generated with Claude Code