@@ -371,7 +371,7 @@ <h2 class="font-medium text-accent">🔥 Stress Test</h2>
371371
372372 < div class ="flex items-center ">
373373 < input id ="st-stream " type ="checkbox " class ="mr-2 ">
374- < label for ="st-stream " class ="text-sm "> Use /crawl/stream </ label >
374+ < label for ="st-stream " class ="text-sm "> Enable streaming mode </ label >
375375 < button id ="st-run "
376376 class ="ml-auto bg-accent text-dark px-4 py-2 rounded hover:bg-opacity-90 font-medium ">
377377 Run Stress Test
@@ -596,6 +596,14 @@ <h2 class="font-medium text-accent">🔥 Stress Test</h2>
596596 forceHighlightElement ( curlCodeEl ) ;
597597 }
598598
599+ // Detect if stream is requested inside payload
600+ function shouldUseStream ( payload ) {
601+ const toBool = ( v ) => v === true || ( typeof v === 'string' && v . toLowerCase ( ) === 'true' ) ;
602+ const fromCrawler = payload && payload . crawler_config && payload . crawler_config . params && payload . crawler_config . params . stream ;
603+ const direct = payload && payload . stream ;
604+ return toBool ( fromCrawler ) || toBool ( direct ) ;
605+ }
606+
599607 // Main run function
600608 async function runCrawl ( ) {
601609 const endpoint = document . getElementById ( 'endpoint' ) . value ;
@@ -611,16 +619,24 @@ <h2 class="font-medium text-accent">🔥 Stress Test</h2>
611619 : { browser_config : cfgJson } ;
612620 }
613621 } catch ( err ) {
614- updateStatus ( 'error' ) ;
615- document . querySelector ( '#response-content code' ) . textContent =
616- JSON . stringify ( { error : err . message } , null , 2 ) ;
617- forceHighlightElement ( document . querySelector ( '#response-content code' ) ) ;
618- return ; // stop run
622+ const codeText = cm . getValue ( ) ;
623+ const streamFlag = / s t r e a m \s * = \s * T r u e / i. test ( codeText ) ;
624+ const isCrawlEndpoint = document . getElementById ( 'endpoint' ) . value === 'crawl' ;
625+ if ( isCrawlEndpoint && streamFlag ) {
626+ // Fallback: proceed with minimal config only for stream
627+ advConfig = { crawler_config : { stream : true } } ;
628+ } else {
629+ updateStatus ( 'error' ) ;
630+ document . querySelector ( '#response-content code' ) . textContent =
631+ JSON . stringify ( { error : err . message } , null , 2 ) ;
632+ forceHighlightElement ( document . querySelector ( '#response-content code' ) ) ;
633+ return ; // stop run
634+ }
619635 }
620636
621637 const endpointMap = {
622638 crawl : '/crawl' ,
623- // crawl_stream: '/crawl/stream',
639+ crawl_stream : '/crawl/stream' , // Keep for backward compatibility
624640 md : '/md' ,
625641 llm : '/llm'
626642 } ;
@@ -647,7 +663,7 @@ <h2 class="font-medium text-accent">🔥 Stress Test</h2>
647663 // This will be handled directly in the fetch below
648664 payload = null ;
649665 } else {
650- // Default payload for /crawl and /crawl/stream
666+ // Default payload for /crawl (supports both streaming and batch modes)
651667 payload = {
652668 urls,
653669 ...advConfig
@@ -659,6 +675,7 @@ <h2 class="font-medium text-accent">🔥 Stress Test</h2>
659675 try {
660676 const startTime = performance . now ( ) ;
661677 let response , responseData ;
678+ const useStreamOverride = ( endpoint === 'crawl' ) && shouldUseStream ( payload ) ;
662679
663680 if ( endpoint === 'llm' ) {
664681 // Special handling for LLM endpoint which uses URL pattern: /llm/{encoded_url}?q={query}
@@ -681,8 +698,8 @@ <h2 class="font-medium text-accent">🔥 Stress Test</h2>
681698 document . querySelector ( '#response-content code' ) . textContent = JSON . stringify ( responseData , null , 2 ) ;
682699 document . querySelector ( '#response-content code' ) . className = 'json hljs' ;
683700 forceHighlightElement ( document . querySelector ( '#response-content code' ) ) ;
684- } else if ( endpoint === 'crawl_stream' ) {
685- // Stream processing
701+ } else if ( endpoint === 'crawl_stream' || useStreamOverride ) {
702+ // Stream processing - now handled directly by /crawl endpoint
686703 response = await fetch ( api , {
687704 method : 'POST' ,
688705 headers : { 'Content-Type' : 'application/json' } ,
@@ -757,6 +774,7 @@ <h2 class="font-medium text-accent">🔥 Stress Test</h2>
757774 const question = document . getElementById ( 'llm-question' ) . value . trim ( ) || "What is this page about?" ;
758775 generateSnippets ( `${ api } /${ encodedUrl } ?q=${ encodeURIComponent ( question ) } ` , null , 'GET' ) ;
759776 } else {
777+ // Use the same API endpoint for both streaming and non-streaming
760778 generateSnippets ( api , payload ) ;
761779 }
762780 } catch ( error ) {
@@ -786,7 +804,7 @@ <h2 class="font-medium text-accent">🔥 Stress Test</h2>
786804 document . getElementById ( 'stress-avg-time' ) . textContent = '0' ;
787805 document . getElementById ( 'stress-peak-mem' ) . textContent = '0' ;
788806
789- const api = useStream ? '/crawl/stream' : ' /crawl' ;
807+ const api = '/crawl' ; // Always use /crawl - backend handles streaming internally
790808 const urls = Array . from ( { length : total } , ( _ , i ) => `https://httpbin.org/anything/stress-${ i } -${ Date . now ( ) } ` ) ;
791809 const chunks = [ ] ;
792810
0 commit comments