File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed
Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -176,16 +176,17 @@ export default function LoginPage({
176176 if ( turnstileSiteKey && turnstileRef . current ) {
177177 try {
178178 turnstileRef . current . reset ( )
179+ let timeoutId : ReturnType < typeof setTimeout > | undefined
179180 token = await Promise . race ( [
180181 new Promise < string > ( ( resolve , reject ) => {
181182 captchaResolveRef . current = resolve
182183 captchaRejectRef . current = reject
183184 turnstileRef . current ?. execute ( )
184185 } ) ,
185- new Promise < string > ( ( _ , reject ) =>
186- setTimeout ( ( ) => reject ( new Error ( 'Captcha timed out' ) ) , 15_000 )
187- ) ,
188- ] )
186+ new Promise < string > ( ( _ , reject ) => {
187+ timeoutId = setTimeout ( ( ) => reject ( new Error ( 'Captcha timed out' ) ) , 15_000 )
188+ } ) ,
189+ ] ) . finally ( ( ) => clearTimeout ( timeoutId ) )
189190 } catch {
190191 setPasswordErrors ( [ 'Captcha verification failed. Please try again.' ] )
191192 setShowValidationError ( true )
Original file line number Diff line number Diff line change @@ -256,16 +256,17 @@ function SignupFormContent({
256256 if ( turnstileSiteKey && turnstileRef . current ) {
257257 try {
258258 turnstileRef . current . reset ( )
259+ let timeoutId : ReturnType < typeof setTimeout > | undefined
259260 token = await Promise . race ( [
260261 new Promise < string > ( ( resolve , reject ) => {
261262 captchaResolveRef . current = resolve
262263 captchaRejectRef . current = reject
263264 turnstileRef . current ?. execute ( )
264265 } ) ,
265- new Promise < string > ( ( _ , reject ) =>
266- setTimeout ( ( ) => reject ( new Error ( 'Captcha timed out' ) ) , 15_000 )
267- ) ,
268- ] )
266+ new Promise < string > ( ( _ , reject ) => {
267+ timeoutId = setTimeout ( ( ) => reject ( new Error ( 'Captcha timed out' ) ) , 15_000 )
268+ } ) ,
269+ ] ) . finally ( ( ) => clearTimeout ( timeoutId ) )
269270 } catch {
270271 setPasswordErrors ( [ 'Captcha verification failed. Please try again.' ] )
271272 setShowValidationError ( true )
You can’t perform that action at this time.
0 commit comments