@@ -169,19 +169,19 @@ function viewTargetsEqual(currViewTarget, nextViewTarget) {
169169class HeaderForm extends Component {
170170 state = EMPTY_STATE ;
171171 componentDidMount ( ) {
172- this . fetchCanceled = false ;
172+ this . fetchCanceler = new AbortController ( ) ;
173+ this . cancelSignal = this . fetchCanceler . signal ;
173174 this . api = this . props . APIInterface ;
174175 this . initState ( ) ;
175176 this . getMountedFilenames ( ) ;
176177 this . setUpWebsocket ( ) ;
177178 }
178179 componentWillUnmount ( ) {
179180 // Cancel the requests since we may have long running requests pending.
180- this . api . abortRequests ( ) ;
181- this . fetchCanceled = true ;
181+ this . fetchCanceler . abort ( ) ;
182182 }
183183 handleFetchError ( error , message ) {
184- if ( ! this . fetchCanceled ) {
184+ if ( ! this . cancelSignal . aborted ) {
185185 console . log ( message , error . name , error . message ) ;
186186 this . setState ( { error : error } ) ;
187187 } else {
@@ -298,7 +298,7 @@ class HeaderForm extends Component {
298298 getMountedFilenames = async ( ) => {
299299 this . setState ( { error : null } ) ;
300300 try {
301- const json = await this . api . getFilenames ( ) ;
301+ const json = await this . api . getFilenames ( this . cancelSignal ) ;
302302 if ( ! json . files || json . files . length === 0 ) {
303303 // We did not get back a graph, only (possibly) an error.
304304 const error =
@@ -349,7 +349,7 @@ class HeaderForm extends Component {
349349 getBedRegions = async ( bedFile ) => {
350350 this . setState ( { error : null } ) ;
351351 try {
352- const json = await this . api . getBedRegions ( bedFile ) ;
352+ const json = await this . api . getBedRegions ( bedFile , this . cancelSignal ) ;
353353 // We need to do all our parsing here, if we expect the catch to catch errors.
354354 if ( ! json . bedRegions || ! ( json . bedRegions [ "desc" ] instanceof Array ) ) {
355355 throw new Error (
@@ -379,7 +379,7 @@ class HeaderForm extends Component {
379379 getPathNames = async ( graphFile ) => {
380380 this . setState ( { error : null } ) ;
381381 try {
382- const json = await this . api . getPathNames ( graphFile ) ;
382+ const json = await this . api . getPathNames ( graphFile , this . cancelSignal ) ;
383383 // We need to do all our parsing here, if we expect the catch to catch errors.
384384 let pathNames = json . pathNames ;
385385 if ( ! ( pathNames instanceof Array ) ) {
@@ -545,7 +545,7 @@ class HeaderForm extends Component {
545545 console . log ( "New tracks have been applied" ) ;
546546 } else if ( this . state . bedFile && chunk ) {
547547 // Try to retrieve tracks from the server
548- const json = await this . api . getChunkTracks ( this . state . bedFile , chunk ) ;
548+ const json = await this . api . getChunkTracks ( this . state . bedFile , chunk , this . cancelSignal ) ;
549549
550550 // Replace tracks if request returns non-falsey value
551551 if ( json . tracks ) {
0 commit comments