Skip to content

fix(auth): implement proper debounce ref for forgot password requests#28490

Open
javidan-io wants to merge 1 commit intocalcom:mainfrom
javidan-io:fix/forgot-password-debounce
Open

fix(auth): implement proper debounce ref for forgot password requests#28490
javidan-io wants to merge 1 commit intocalcom:mainfrom
javidan-io:fix/forgot-password-debounce

Conversation

@javidan-io
Copy link

What does this PR do?

This PR fixes a bug in the ForgotPassword component where the debounced submit function was being recreated on every React render. By moving the lodash.debounce wrapper into a useRef, we ensure the debounce timer properly persists across renders.

Additionally, it removes an unnecessary async/await from handleSubmit since lodash.debounce does not return a Promise, preventing misleading execution flows.

Visual Demo (For contributors especially)

N/A - This is a logic/performance fix with no visual changes to the UI.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox. (N/A)
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Open apps/web/modules/auth/forgot-password/forgot-password-view.tsx locally and temporarily comment out the if (loading) { return; } check inside handleSubmit.
  2. Run the application locally and navigate to /auth/forgot-password.
  3. Open your browser's Developer Tools and go to the Network tab.
  4. Enter an email address.
  5. Rapidly double-click (or spam) the "Request password reset" button.
  6. Verify in the Network tab that only one request is made to /api/auth/forgot-password, confirming the debounce is working correctly.
  7. (Don't forget to uncomment the loading check afterwards!)

Checklist

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


javidan seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file


Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants