Skip to content

Conversation

@juliesaia
Copy link
Contributor

@juliesaia juliesaia commented Jan 25, 2026

When setting fetchOptions: {throw: true} on your auth client, all authenticated convex functions will fail with "unauthenticated".

This is because fetchAccessToken assumes that authClient.convex.token() will return {data, error}. When throw is set to true, it just returns the data as is.

This PR sets fetch: false to this one call so the returned object is always correct. Not 100% sure if this is the cleanest solution, but this is the only time the users authClient itself is used anywhere in the package so i imagine its probably fine. Just wanted to submit a fix of some kind :)


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling for authentication token fetching to prevent application interruption when network errors occur.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Jan 25, 2026

@juliesaia is attempting to deploy a commit to the Convex Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Jan 25, 2026

📝 Walkthrough

Walkthrough

Modified the token fetch in useAuthFromBetterAuth to use fetchOptions: { throw: false }, preventing the function from throwing on fetch errors. The surrounding logic for deriving token from data, updating cache, and returning the token remains unchanged, with the catch block still handling unexpected errors.

Changes

Cohort / File(s) Summary
Token fetch error handling
src/react/index.tsx
Changed authClient.convex.token() call to authClient.convex.token with fetchOptions: { throw: false } to prevent throwing on fetch errors while maintaining existing token derivation and caching logic

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A token fetch, now calm and wise,
No throws when networks fail in disguise,
Graceful errors handled with care,
The rabbit hops through data laid bare! 🌿✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title states 'Fix fetchOptions: {throw: true}' but the actual change sets throw: false to work around the issue, which is the opposite of what the title suggests. Update the title to accurately reflect the fix, such as 'Fix auth token fetch by setting fetchOptions: {throw: false}' or similar to clarify the actual change.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant