Skip to content

fix(ui): AuthProvider SSR crash with partial auth SDK (#2302)#2308

Merged
viniciusdacal merged 4 commits into
mainfrom
viniciusdacal/fix-auth-ssr-crash
Apr 5, 2026
Merged

fix(ui): AuthProvider SSR crash with partial auth SDK (#2302)#2308
viniciusdacal merged 4 commits into
mainfrom
viniciusdacal/fix-auth-ssr-crash

Conversation

@viniciusdacal
Copy link
Copy Markdown
Contributor

Summary

  • Guard auth SDK property access during SSR: auth.signIn?.url ?? '' and auth.signUp?.url ?? '' prevent TypeError when auth SDK methods are undefined in the Rust V8 isolate
  • Runtime guard for SDK method calls: signIn/signUp async bodies check typeof auth.signIn === 'function' and return an error Result instead of crashing when SDK methods are unavailable
  • 6 new tests covering: undefined SDK crash prevention, missing metadata tolerance, default value verification, callable guard, and happy-path regression

Public API Changes

None. Internal defensive fix only — AuthProvider props and useAuth() return type are unchanged.

Related

Closes #2302

Files Changed

Test plan

  • Tests pass: bun test src/auth/__tests__/auth-context.test.ts — 63/63 pass
  • Typecheck: tsc --noEmit — clean
  • Lint: oxlint — 0 errors (warnings are pre-existing)
  • Format: oxfmt --check — clean
  • Pre-push hooks (build + typecheck + test + lint + format) — all pass

🤖 Generated with Claude Code

viniciusdacal and others added 4 commits April 4, 2026 22:15
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>
@viniciusdacal viniciusdacal merged commit 46397c6 into main Apr 5, 2026
8 checks passed
This was referenced Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(runtime): AuthProvider crashes during SSR — auth SDK not available in V8 isolate

1 participant