File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -339,7 +339,9 @@ export class HttpXhrBackend implements HttpBackend {
339339 }
340340
341341 // Finally, abort the in-flight request.
342- xhr . abort ( ) ;
342+ if ( xhr . readyState !== xhr . DONE ) {
343+ xhr . abort ( ) ;
344+ }
343345 } ;
344346 } ) ;
345347 }
Original file line number Diff line number Diff line change @@ -147,6 +147,17 @@ const XSSI_PREFIX = ')]}\'\n';
147147 } ) ;
148148 factory . mock . mockErrorEvent ( new Error ( 'blah' ) ) ;
149149 } ) ;
150+ it ( 'avoids abort a request when fetch operation is completed' , done => {
151+ const abort = jasmine . createSpy ( 'abort' ) ;
152+
153+ backend . handle ( TEST_POST ) . toPromise ( ) . then ( ( ) => {
154+ expect ( abort ) . not . toHaveBeenCalled ( ) ;
155+ done ( ) ;
156+ } ) ;
157+
158+ factory . mock . abort = abort ;
159+ factory . mock . mockFlush ( 200 , 'OK' , 'Done' ) ;
160+ } ) ;
150161 describe ( 'progress events' , ( ) => {
151162 it ( 'are emitted for download progress' , done => {
152163 backend . handle ( TEST_POST . clone ( { reportProgress : true } ) )
You can’t perform that action at this time.
0 commit comments