[GH-ISSUE #740] Error Handling in authClient.signIn.email Doesn't Catch All Errors #17035

Closed
opened 2026-04-15 14:58:47 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @adrian-kong on GitHub (Dec 3, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/740

Describe the bug
The authClient.signIn.email function, as implemented from the docs, fails to catch all errors, such as Cross-Origin Request Blocked errors caused by CORS policy violations. This happens because the current implementation relies solely on the onError callback provided in the options, which does not account for errors thrown at a higher level.

To Reproduce

As example in docs:

      await authClient.signIn.email(
        { email, password },
        {
          onRequest: () => {
          },
          onSuccess: () => {
          },
          onError: (ctx) => {
            console.error(ctx.error.message);
          },
        }
      );

will error in backend

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource

Expected behavior
onError should handle the error or docs to be updated with try catch

Originally created by @adrian-kong on GitHub (Dec 3, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/740 **Describe the bug** The authClient.signIn.email function, as implemented from the docs, fails to catch all errors, such as Cross-Origin Request Blocked errors caused by CORS policy violations. This happens because the current implementation relies solely on the onError callback provided in the options, which does not account for errors thrown at a higher level. **To Reproduce** As example in docs: ```js await authClient.signIn.email( { email, password }, { onRequest: () => { }, onSuccess: () => { }, onError: (ctx) => { console.error(ctx.error.message); }, } ); ``` will error in backend ``` Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource ``` **Expected behavior** onError should handle the error or docs to be updated with try catch
GiteaMirror added the locked label 2026-04-15 14:58:47 -05:00
Author
Owner

@Bekacru commented on GitHub (Dec 3, 2024):

that's is intentional behavior. It only supposed to catch api returned errors.

<!-- gh-comment-id:2514322283 --> @Bekacru commented on GitHub (Dec 3, 2024): that's is intentional behavior. It only supposed to catch api returned errors.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#17035