@@ -77,6 +77,9 @@ export const getTurnstileToken = async (opts: CaptchaOptions) => {
7777 const { modalContainerQuerySelector, modalWrapperQuerySelector, closeModal, openModal } = opts ;
7878 const captcha : Turnstile . Turnstile = await loadCaptcha ( nonce ) ;
7979
80+ // Error codes array - used for actual error handling (unchanged from original behavior)
81+ const errorCodes : ( string | number ) [ ] = [ ] ;
82+
8083 // Diagnostic tracking - wrapped in try-catch to never affect production behavior
8184 let startTime = 0 ;
8285 let errorTimeline : Array < { code : string | number ; t : number } > = [ ] ;
@@ -195,6 +198,9 @@ export const getTurnstileToken = async (opts: CaptchaOptions) => {
195198 }
196199 } ,
197200 'error-callback' : function ( errorCode ) {
201+ // Track error for actual error handling (original behavior)
202+ errorCodes . push ( errorCode ) ;
203+ // Track timing for diagnostics only
198204 try {
199205 errorTimeline . push ( { code : errorCode , t : Date . now ( ) - startTime } ) ;
200206 } catch {
@@ -211,7 +217,7 @@ export const getTurnstileToken = async (opts: CaptchaOptions) => {
211217 } , 250 ) ;
212218 return ;
213219 }
214- reject ( [ errorTimeline . map ( e => e . code ) . join ( ',' ) , id ] ) ;
220+ reject ( [ errorCodes . join ( ',' ) , id ] ) ;
215221 } ,
216222 'unsupported-callback' : function ( ) {
217223 reject ( [ 'This browser is not supported by the CAPTCHA.' , id ] ) ;
0 commit comments