mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Merge pull request #6651 from spalger/fix/courier/requestAlreadyStarted
Fix courier "request already started" bug
This commit is contained in:
commit
fe5ec6cf0f
4 changed files with 15 additions and 9 deletions
|
@ -20,6 +20,8 @@ export default function CourierFetchCallClient(Private, Promise, es, esShardTime
|
|||
const executable = statuses.filter(isRequest);
|
||||
let execCount = executable.length;
|
||||
|
||||
if (!execCount) return Promise.resolve([]);
|
||||
|
||||
// resolved by respond()
|
||||
let esPromise;
|
||||
const defer = Promise.defer();
|
||||
|
|
|
@ -29,22 +29,26 @@ export default function FetchTheseProvider(Private, Promise) {
|
|||
}
|
||||
|
||||
function fetchWithStrategy(strategy, requests) {
|
||||
function replaceAbortedRequests() {
|
||||
requests = requests.map(r => r.aborted ? ABORTED : r);
|
||||
}
|
||||
|
||||
requests = requests.map(function (req) {
|
||||
return req.aborted ? ABORTED : req;
|
||||
});
|
||||
|
||||
replaceAbortedRequests();
|
||||
return startRequests(requests)
|
||||
.then(function () {
|
||||
replaceAbortedRequests();
|
||||
return callClient(strategy, requests);
|
||||
})
|
||||
.then(function (responses) {
|
||||
replaceAbortedRequests();
|
||||
return callResponseHandlers(requests, responses);
|
||||
})
|
||||
.then(function (responses) {
|
||||
replaceAbortedRequests();
|
||||
return continueIncomplete(strategy, requests, responses, fetchWithStrategy);
|
||||
})
|
||||
.then(function (responses) {
|
||||
replaceAbortedRequests();
|
||||
return responses.map(function (resp) {
|
||||
switch (resp) {
|
||||
case ABORTED:
|
||||
|
|
|
@ -32,9 +32,7 @@ describe('ui/courier/fetch/request/segmented', () => {
|
|||
expect(returned.then).to.be.Function;
|
||||
});
|
||||
|
||||
it('does not call super.start() until promise is resolved', () => {
|
||||
expect(searchReqStart.called).to.be(false);
|
||||
$rootScope.$apply();
|
||||
it('calls super.start() synchronously', () => {
|
||||
expect(searchReqStart.called).to.be(true);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -42,6 +42,8 @@ export default function SegmentedReqProvider(es, Private, Promise, timefilter, c
|
|||
*********/
|
||||
|
||||
start() {
|
||||
super.start();
|
||||
|
||||
this._complete = [];
|
||||
this._active = null;
|
||||
this._segments = [];
|
||||
|
@ -61,12 +63,12 @@ export default function SegmentedReqProvider(es, Private, Promise, timefilter, c
|
|||
// parameters via the handle
|
||||
if (_.isFunction(this._initFn)) this._initFn(this._handle);
|
||||
return this._createQueue().then((queue) => {
|
||||
if (this.stopped) return;
|
||||
|
||||
this._all = queue.slice(0);
|
||||
|
||||
// Send the initial fetch status
|
||||
this._reportStatus();
|
||||
|
||||
return super.start();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue