Skip to content

fix: better-auth better error catch#892

Merged
graphite-app[bot] merged 1 commit intomainfrom
04-28-fix_better-auth_better_error_catch
Apr 28, 2026
Merged

fix: better-auth better error catch#892
graphite-app[bot] merged 1 commit intomainfrom
04-28-fix_better-auth_better_error_catch

Conversation

@MaheshtheDev
Copy link
Copy Markdown
Member

No description provided.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 28, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
supermemory-mcp 1c80d43 Apr 28 2026, 11:48 PM

@MaheshtheDev MaheshtheDev marked this pull request as ready for review April 28, 2026 23:33
Copy link
Copy Markdown
Member Author


How to use the Graphite Merge Queue

Add the label Main to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown

claude Bot commented Apr 28, 2026

Claude finished @MaheshtheDev's task in 2m 57s —— View job


PR Review: better-auth better error catch

  • Fetch PR diff and review comments
  • Analyze changed files for bugs/security issues
  • Submit review

Summary: The magic link error handling is correctly updated to use return-based error checking. However, the social sign-in flows (Google/GitHub) add .catch() handlers that won't work as expected — with throw: true removed, API errors are returned as { error }, not thrown. The .catch() handlers will only catch network failures, while API errors (rate limiting, validation) will be silently ignored. See my review comment for a suggested fix.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 28, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
supermemory-app 1c80d43 Commit Preview URL Apr 28 2026, 11:49 PM

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview: This PR switches better-auth from throw-based to return-based error handling by removing throw: true from the auth client config.

Issues found:

The magic link flow is correctly updated to destructure { error } from the response and check it. However, the social sign-in flows (Google/GitHub) only add .catch() handlers which won't work as expected:

  • With throw: true removed, API errors are returned as { error } in the response object, not thrown as exceptions
  • The .catch() handlers only catch thrown errors (like network failures), not returned { error } values
  • If signIn.social() fails before redirecting (e.g., rate limiting, server validation), the error will be silently ignored — the user will see loading stop but no error message

Suggested fix for apps/web/app/(auth)/login/new/page.tsx lines 358-360 and 425-427:

// Instead of:
.catch((err: unknown) => {
  setError(getErrorMessage(err))
})

// Consider:
.then(({ error }) => {
  if (error) setError(getErrorMessage(error))
})

This matches the pattern used for magic link handling and ensures API errors are properly displayed.

Score: 7/10

The magic link fix is correct. The social sign-in error handling needs adjustment to catch returned errors, not just thrown exceptions.

@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented Apr 28, 2026

Merge activity

@graphite-app graphite-app Bot force-pushed the 04-28-fix_better-auth_better_error_catch branch from cfff3d8 to 1c80d43 Compare April 28, 2026 23:46
@graphite-app graphite-app Bot merged commit 1c80d43 into main Apr 28, 2026
7 of 8 checks passed
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.

2 participants