@@ -461,16 +461,6 @@ export const authenticateRequest: AuthenticateRequest = (async (
461461 }
462462 }
463463 }
464- /**
465- * Otherwise, check for "known unknown" auth states that we can resolve with a handshake.
466- */
467- if (
468- authenticateContext . instanceType === 'development' &&
469- authenticateContext . clerkUrl . searchParams . has ( constants . QueryParameters . DevBrowser )
470- ) {
471- return handleMaybeHandshakeStatus ( authenticateContext , AuthErrorReason . DevBrowserSync , '' ) ;
472- }
473-
474464 const isRequestEligibleForMultiDomainSync =
475465 authenticateContext . isSatellite && authenticateContext . secFetchDest === 'document' ;
476466
@@ -500,7 +490,9 @@ export const authenticateRequest: AuthenticateRequest = (async (
500490 return handleMaybeHandshakeStatus ( authenticateContext , AuthErrorReason . SatelliteCookieNeedsSyncing , '' , headers ) ;
501491 }
502492
503- // Multi-domain development sync flow
493+ // Multi-domain development sync flow - primary responds to syncing
494+ // IMPORTANT: This must come BEFORE dev-browser-sync check to avoid the root domain
495+ // triggering its own handshakes when it's in the middle of handling a satellite sync request
504496 const redirectUrl = new URL ( authenticateContext . clerkUrl ) . searchParams . get (
505497 constants . QueryParameters . ClerkRedirectUrl ,
506498 ) ;
@@ -524,6 +516,16 @@ export const authenticateRequest: AuthenticateRequest = (async (
524516 * End multi-domain sync flows
525517 */
526518
519+ /**
520+ * Otherwise, check for "known unknown" auth states that we can resolve with a handshake.
521+ */
522+ if (
523+ authenticateContext . instanceType === 'development' &&
524+ authenticateContext . clerkUrl . searchParams . has ( constants . QueryParameters . DevBrowser )
525+ ) {
526+ return handleMaybeHandshakeStatus ( authenticateContext , AuthErrorReason . DevBrowserSync , '' ) ;
527+ }
528+
527529 if ( authenticateContext . instanceType === 'development' && ! hasDevBrowserToken ) {
528530 return handleMaybeHandshakeStatus ( authenticateContext , AuthErrorReason . DevBrowserMissing , '' ) ;
529531 }
0 commit comments