fix: resolve stale closure race condition in face scan timeout#1422
fix: resolve stale closure race condition in face scan timeout#1422Janeeshareddy wants to merge 4 commits into
Conversation
… CaseAssignment components
|
@Janeeshareddy is attempting to deploy a commit to the CodeBlooded's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Hi @Janeeshareddy, thanks for contributing to Nyay Setu! 🎉 I have automatically:
Our workflows will now analyze your changes to classify:
Tip Ensure your PR description references the issue it resolves (e.g. Happy coding! 🚀 |
viru0909-dev
left a comment
There was a problem hiding this comment.
⚠️ Please Isolate Your Changes
Your fix for the face scan timeout bug using timeoutRef is correct and exactly what we need!
However, this PR accidentally includes over 700 lines of unrelated code for a new 'Lawyer Matching' feature (e.g., LawyerMatchingService, CaseAssignmentController, CaseAssignment.jsx).
Could you please clean up this branch so that it only includes the changes to FaceLoginModal.jsx? We can't merge the lawyer assignment logic as part of this bug fix.
viru0909-dev
left a comment
There was a problem hiding this comment.
PR contains unrelated files that have already been merged (e.g. CaseAssignmentController, LawyerMatchingService). Please rebase your branch on the latest main and only include the FaceLoginModal.jsx changes to resolve the timeout issue cleanly.
Fixes #1413
Root Cause
The original
setTimeoutinsidestartFaceDetectionclosed overstepandfaceDetectedstate values at creation time. Even when face detection succeeded and step transitioned tosuccess, the timeout still saw stale values (step === 'scanning',faceDetected === false) and incorrectly fired the error state.Changes
timeoutRef(useRef) to store the 45s timeout ID explicitlyscanActiveRef(useRef) to track if the scan session is still activehandleFaceLoginwhen face is confirmeduseEffectcleanup to cancel timeout on step change or component unmountscanActiveRef.currentBenefits