@@ -537,7 +537,7 @@ require([
537537 this . queues . bytes_downloaded += downloaded_amount ;
538538 }
539539
540- pendingfetchMessage ( fetch_type ) {
540+ pendingFetchMessage ( fetch_type ) {
541541 // Don't display if we already have pending downloads
542542 if ( this . in_progress > 0 ) {
543543 return ;
@@ -674,6 +674,14 @@ require([
674674 this . downloadWorkers . forEach ( worker => {
675675 worker . postMessage ( { 'abort' : true , 'reason' : 'User cancelled download.' } ) ;
676676 } ) ;
677+ // Sometimes worker latency can cause a race condition between final cleanup and resetting the download
678+ // manager's state. Run trigger a final time after waiting a couple of seconds to be totally sure
679+ // we've cleaned up after ourselves.
680+ setTimeout ( 2000 , function ( ) {
681+ if ( downloader_manager . pending_cancellation ) {
682+ downloader_manager . triggerWorkerDownloads ( ) ;
683+ }
684+ } ) ;
677685 }
678686
679687 set_download_stats ( stats ) {
@@ -713,7 +721,7 @@ require([
713721 return ;
714722 }
715723 let job_result = await series_job . json ( ) ;
716- downloader_manager . pendingfetchMessage ( "collection" ) ;
724+ downloader_manager . pendingFetchMessage ( "collection" ) ;
717725
718726 const MAX_ELAPSED_SERIES_IDS = 8000 ;
719727 let polling = async function ( file_name , check_start ) {
@@ -782,6 +790,7 @@ require([
782790 } else {
783791 let response = null ;
784792 if ( [ "cohort" , "cart" ] . includes ( download_type ) ) {
793+ downloader_manager . pendingFetchMessage ( download_type ) ;
785794 let filter_and_cart = { } ;
786795 if ( download_type === "cohort" ) {
787796 let filtergrp_list = [ ] ;
0 commit comments