fix(http): avoid abort a request when fetch operation is completed (#37367)

`abort` method is calling, even if fetch operation is completed

Fixes https://github.com/angular/angular/issues/36537

PR Close #37367
This commit is contained in:
Dmitrij Kuba 2020-05-31 17:32:21 +03:00 committed by Andrew Kushnir
parent ef1fb6dee4
commit 8a74508130
2 changed files with 14 additions and 1 deletions

View File

@ -339,7 +339,9 @@ export class HttpXhrBackend implements HttpBackend {
}
// Finally, abort the in-flight request.
xhr.abort();
if (xhr.readyState !== xhr.DONE) {
xhr.abort();
}
};
});
}

View File

@ -147,6 +147,17 @@ const XSSI_PREFIX = ')]}\'\n';
});
factory.mock.mockErrorEvent(new Error('blah'));
});
it('avoids abort a request when fetch operation is completed', done => {
const abort = jasmine.createSpy('abort');
backend.handle(TEST_POST).toPromise().then(() => {
expect(abort).not.toHaveBeenCalled();
done();
});
factory.mock.abort = abort;
factory.mock.mockFlush(200, 'OK', 'Done');
});
describe('progress events', () => {
it('are emitted for download progress', done => {
backend.handle(TEST_POST.clone({reportProgress: true}))