Skip to content

Commit a2e4572

Browse files
committed
fix(clerk-js): Preserve original error codes array, use timeline only for diagnostics
1 parent 26af31d commit a2e4572

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/clerk-js/src/utils/captcha/turnstile.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)