Plugin: Passkey - addPasskey is missing error code in Promise #945

Closed
opened 2026-03-13 08:10:59 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @DimitarY on GitHub (Mar 29, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. setup better auth to use passkeys
  2. attempt to use add passkey when session is not fresh

Current vs. Expected behavior

current: authClient.passkey.addPasskey function does not have a error code are return type
expected: authClient.passkey.addPasskey function include error code as return type

What version of Better Auth are you using?

1.2.5

Provide environment information

- OS: Rocky Linux 9
- Browser: Firefox

Which area(s) are affected? (Select all that apply)

Types

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

No response

Originally created by @DimitarY on GitHub (Mar 29, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. setup better auth to use passkeys 3. attempt to use add passkey when session is not fresh ### Current vs. Expected behavior current: authClient.passkey.addPasskey function does not have a error code are return type expected: authClient.passkey.addPasskey function include error code as return type ### What version of Better Auth are you using? 1.2.5 ### Provide environment information ```bash - OS: Rocky Linux 9 - Browser: Firefox ``` ### Which area(s) are affected? (Select all that apply) Types ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 08:10:59 -05:00
Author
Owner

@Korabi123 commented on GitHub (Jun 16, 2025):

+1 did you find any way to get around this/display an error state when this error occurs?

@Korabi123 commented on GitHub (Jun 16, 2025): +1 did you find any way to get around this/display an error state when this error occurs?
Author
Owner

@DimitarY commented on GitHub (Jun 20, 2025):

This is working for me at the moment

const result = await auth.passkey.addPasskey({ name: values.name });

console.log("result", result);

if (result?.error) {
  return {
    success: false,
    error: result.error as {
      code?: string | undefined;
      message?: string | undefined;
      status: number;
      statusText: string;
    },
  };
} else {
  return { success: true, error: null };
}
@DimitarY commented on GitHub (Jun 20, 2025): This is working for me at the moment ```typescript const result = await auth.passkey.addPasskey({ name: values.name }); console.log("result", result); if (result?.error) { return { success: false, error: result.error as { code?: string | undefined; message?: string | undefined; status: number; statusText: string; }, }; } else { return { success: true, error: null }; } ```
Author
Owner

@Korabi123 commented on GitHub (Jul 8, 2025):

This is working for me at the moment

const result = await auth.passkey.addPasskey({ name: values.name });

console.log("result", result);

if (result?.error) {
return {
success: false,
error: result.error as {
code?: string | undefined;
message?: string | undefined;
status: number;
statusText: string;
},
};
} else {
return { success: true, error: null };
}

so in the if statement could I save the error message to a state variable or would I have to it somewhere else?

@Korabi123 commented on GitHub (Jul 8, 2025): > This is working for me at the moment > > const result = await auth.passkey.addPasskey({ name: values.name }); > > console.log("result", result); > > if (result?.error) { > return { > success: false, > error: result.error as { > code?: string | undefined; > message?: string | undefined; > status: number; > statusText: string; > }, > }; > } else { > return { success: true, error: null }; > } so in the if statement could I save the error message to a state variable or would I have to it somewhere else?
Author
Owner

@ping-maxwell commented on GitHub (Oct 5, 2025):

Hello all, this was fixed in https://github.com/better-auth/better-auth/pull/3966

@ping-maxwell commented on GitHub (Oct 5, 2025): Hello all, this was fixed in https://github.com/better-auth/better-auth/pull/3966
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#945