Skip to content

Commit

Permalink
[maps] abort sync data if any data request fails (elastic#87381)
Browse files Browse the repository at this point in the history
* [maps] abort sync data if any data request fails

* review feedback

* fix broken rename of e to error

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
nreese and kibanamachine committed Jan 11, 2021
1 parent 68e367d commit 02f1527
Showing 1 changed file with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -384,14 +384,11 @@ export class VectorLayer extends AbstractLayer {
join,
propertiesMap,
};
} catch (e) {
if (!(e instanceof DataRequestAbortError)) {
onLoadError(sourceDataId, requestToken, `Join error: ${e.message}`);
} catch (error) {
if (!(error instanceof DataRequestAbortError)) {
onLoadError(sourceDataId, requestToken, `Join error: ${error.message}`);
}
return {
dataHasChanged: true,
join,
};
throw error;
}
}

Expand Down Expand Up @@ -430,7 +427,7 @@ export class VectorLayer extends AbstractLayer {
};
}

async _performInnerJoins(
_performInnerJoins(
sourceResult: SourceResult,
joinStates: JoinState[],
updateSourceData: DataRequestContext['updateSourceData']
Expand Down Expand Up @@ -538,9 +535,7 @@ export class VectorLayer extends AbstractLayer {
if (!(error instanceof DataRequestAbortError)) {
onLoadError(dataRequestId, requestToken, error.message);
}
return {
refreshed: false,
};
throw error;
}
}

Expand Down Expand Up @@ -646,6 +641,7 @@ export class VectorLayer extends AbstractLayer {
if (!(error instanceof DataRequestAbortError)) {
onLoadError(dataRequestId, requestToken, error.message);
}
throw error;
}
}

Expand Down Expand Up @@ -736,6 +732,7 @@ export class VectorLayer extends AbstractLayer {
stopLoading(dataRequestId, requestToken, formatters, nextMeta);
} catch (error) {
onLoadError(dataRequestId, requestToken, error.message);
throw error;
}
}

Expand All @@ -757,19 +754,26 @@ export class VectorLayer extends AbstractLayer {
if (this.isLoadingBounds()) {
return;
}
await this._syncSourceStyleMeta(syncContext, source, style);
await this._syncSourceFormatters(syncContext, source, style);
const sourceResult = await this._syncSource(syncContext, source, style);
if (
!sourceResult.featureCollection ||
!sourceResult.featureCollection.features.length ||
!this.hasJoins()
) {
return;
}

const joinStates = await this._syncJoins(syncContext, style);
await this._performInnerJoins(sourceResult, joinStates, syncContext.updateSourceData);
try {
await this._syncSourceStyleMeta(syncContext, source, style);
await this._syncSourceFormatters(syncContext, source, style);
const sourceResult = await this._syncSource(syncContext, source, style);
if (
!sourceResult.featureCollection ||
!sourceResult.featureCollection.features.length ||
!this.hasJoins()
) {
return;
}

const joinStates = await this._syncJoins(syncContext, style);
this._performInnerJoins(sourceResult, joinStates, syncContext.updateSourceData);
} catch (error) {
if (!(error instanceof DataRequestAbortError)) {
throw error;
}
}
}

_getSourceFeatureCollection() {
Expand Down

0 comments on commit 02f1527

Please sign in to comment.