@@ -42,6 +42,9 @@ export const setupClerkTestingToken = async ({ context, options, page }: SetupCl
4242 }
4343
4444 if ( setupContexts . has ( browserContext ) ) {
45+ if ( process . env . CLERK_TESTING_DEBUG ) {
46+ console . log ( '[Clerk Testing] Route handler already registered for this context, skipping duplicate setup' ) ;
47+ }
4548 return ;
4649 }
4750 setupContexts . add ( browserContext ) ;
@@ -72,6 +75,11 @@ export const setupClerkTestingToken = async ({ context, options, page }: SetupCl
7275 if ( RETRYABLE_STATUS_CODES . has ( status ) ) {
7376 if ( attempt < MAX_ROUTE_RETRIES ) {
7477 const delay = BASE_DELAY_MS * Math . pow ( 2 , attempt ) + Math . random ( ) * JITTER_MAX_MS ;
78+ if ( process . env . CLERK_TESTING_DEBUG ) {
79+ console . log (
80+ `[Clerk Testing] FAPI returned ${ status } , retrying (attempt ${ attempt + 1 } /${ MAX_ROUTE_RETRIES } , delay ${ Math . round ( delay ) } ms): ${ route . request ( ) . url ( ) } ` ,
81+ ) ;
82+ }
7583 await new Promise ( resolve => setTimeout ( resolve , delay ) ) ;
7684 continue ;
7785 }
@@ -100,6 +108,12 @@ export const setupClerkTestingToken = async ({ context, options, page }: SetupCl
100108 } catch ( error ) {
101109 if ( attempt < MAX_ROUTE_RETRIES ) {
102110 const delay = BASE_DELAY_MS * Math . pow ( 2 , attempt ) + Math . random ( ) * JITTER_MAX_MS ;
111+ if ( process . env . CLERK_TESTING_DEBUG ) {
112+ console . log (
113+ `[Clerk Testing] FAPI request error, retrying (attempt ${ attempt + 1 } /${ MAX_ROUTE_RETRIES } , delay ${ Math . round ( delay ) } ms): ${ route . request ( ) . url ( ) } ` ,
114+ error ,
115+ ) ;
116+ }
103117 await new Promise ( resolve => setTimeout ( resolve , delay ) ) ;
104118 continue ;
105119 }
0 commit comments