@@ -587,15 +587,49 @@ export const useBroadcastController = (): BroadcastStreamController => {
587587 error : null ,
588588 } ) )
589589
590+ // Set up a timeout to handle rounds with no data (future rounds)
591+ const timeoutId = setTimeout ( ( ) => {
592+ console . log (
593+ 'Stream timeout - no data received, likely future/empty round' ,
594+ )
595+ if ( abortController . current && currentRoundId . current === roundId ) {
596+ // Set empty round data instead of staying in connecting state
597+ setRoundData ( {
598+ roundId : roundId ,
599+ broadcastId : currentBroadcast ?. tour . id || '' ,
600+ games : new Map ( ) ,
601+ lastUpdate : Date . now ( ) ,
602+ } )
603+
604+ setBroadcastState ( {
605+ isConnected : true ,
606+ isConnecting : false ,
607+ isLive : false ,
608+ error : null ,
609+ roundStarted : true ,
610+ roundEnded : false ,
611+ gameEnded : false ,
612+ } )
613+ }
614+ } , 5000 ) // 5 second timeout
615+
590616 try {
591617 // Start streaming - this will send all games initially, then updates
592618 await streamBroadcastRound (
593619 roundId ,
594- handlePGNUpdate ,
595- handleStreamComplete ,
620+ ( pgnData ) => {
621+ // Clear timeout if we receive data
622+ clearTimeout ( timeoutId )
623+ handlePGNUpdate ( pgnData )
624+ } ,
625+ ( ) => {
626+ clearTimeout ( timeoutId )
627+ handleStreamComplete ( )
628+ } ,
596629 abortController . current . signal ,
597630 )
598631 } catch ( error ) {
632+ clearTimeout ( timeoutId )
599633 console . error ( 'Round stream error:' , error )
600634
601635 const errorMessage =
@@ -614,7 +648,7 @@ export const useBroadcastController = (): BroadcastStreamController => {
614648 abortController . current = null
615649 }
616650 } ,
617- [ handlePGNUpdate , handleStreamComplete ] ,
651+ [ handlePGNUpdate , handleStreamComplete , currentBroadcast ] ,
618652 )
619653
620654 const reconnect = useCallback ( ( ) => {
0 commit comments