Skip to content

separate error handling for account creation and profile update in s… - #340

Merged
Nitya-003 merged 1 commit into
Nitya-003:mainfrom
khushboo-khatoon:fix/signup-false-failure-on-updateprofile-error
Jul 24, 2026
Merged

separate error handling for account creation and profile update in s…#340
Nitya-003 merged 1 commit into
Nitya-003:mainfrom
khushboo-khatoon:fix/signup-false-failure-on-updateprofile-error

Conversation

@khushboo-khatoon

Copy link
Copy Markdown
Contributor

Fixes #338

Description

Previously, createUserWithEmailAndPassword and updateProfile were both wrapped inside a single try/catch block in signupform.tsx. This meant that if account creation succeeded but updateProfile failed (e.g. due to a network blip), the user was shown a generic "Signup failed" message — even though their account was actually created successfully in Firebase Auth.

This caused confusion: users would think signup failed and retry with the same email, only to hit an auth/email-already-in-use error, without realizing an account already existed for them.

Changes

  • Split the single try/catch into two separate blocks:
    • One around createUserWithEmailAndPassword — a failure here is a real signup failure, so the user sees the "Signup failed" toast/message and the function returns early.
    • One around updateProfile — a failure here is now non-blocking. It's logged via console.error for debugging, but the user is not shown an error, since their account was already created successfully.
  • Success toast and redirect (router.push("/")) now run after both steps, so the user only ever sees a real failure when the account genuinely wasn't created.

Before

try {
  const userCredential = await createUserWithEmailAndPassword(auth, data.email, data.password);
  await updateProfile(userCredential.user, { displayName: data.name });
  toast.success("Account Created!");
  router.push("/");
} catch (error) {
  // Runs for EITHER failure — can't tell which step broke
  toast.error("Signup failed", { description: error.message });
}

After

let userCredential;
try {
  userCredential = await createUserWithEmailAndPassword(auth, data.email, data.password);
} catch (error) {
  toast.error("Signup failed", { description: error.message });
  return;
}

try {
  await updateProfile(userCredential.user, { displayName: data.name });
} catch (profileError) {
  console.error("Failed to set display name:", profileError);
  // Non-blocking — account already created successfully
}

toast.success("Account Created!");
router.push("/");

Impact

Users will no longer see a false "Signup failed" message when their account was actually created successfully, preventing confusion and duplicate signup attempts.

Checklist

  • Code builds and runs locally
  • Manually tested both success and failure paths

@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown

@khushboo-khatoon is attempting to deploy a commit to the Nitya Gosain's projects Team on Vercel.

A member of the Team first needs to authorize it.

@khushboo-khatoon

Copy link
Copy Markdown
Contributor Author

hey @Nitya-003 ,
PR is now ready to review and merge , please lemme know if any changes needed .

@Nitya-003
Nitya-003 merged commit 1044b0c into Nitya-003:main Jul 24, 2026
3 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Signup shows "failed" even when the account was actually created

2 participants