From 89e7cd6808df0330962605415374564851d594cc Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Mon, 11 Jan 2021 12:28:24 -0700 Subject: [PATCH] [maps] abort sync data if any data request fails (#87381) * [maps] abort sync data if any data request fails * review feedback * fix broken rename of e to error Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../layers/vector_layer/vector_layer.tsx | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/x-pack/plugins/maps/public/classes/layers/vector_layer/vector_layer.tsx b/x-pack/plugins/maps/public/classes/layers/vector_layer/vector_layer.tsx index f72d2c0e6ead..0cb24be445c6 100644 --- a/x-pack/plugins/maps/public/classes/layers/vector_layer/vector_layer.tsx +++ b/x-pack/plugins/maps/public/classes/layers/vector_layer/vector_layer.tsx @@ -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; } } @@ -430,7 +427,7 @@ export class VectorLayer extends AbstractLayer { }; } - async _performInnerJoins( + _performInnerJoins( sourceResult: SourceResult, joinStates: JoinState[], updateSourceData: DataRequestContext['updateSourceData'] @@ -538,9 +535,7 @@ export class VectorLayer extends AbstractLayer { if (!(error instanceof DataRequestAbortError)) { onLoadError(dataRequestId, requestToken, error.message); } - return { - refreshed: false, - }; + throw error; } } @@ -646,6 +641,7 @@ export class VectorLayer extends AbstractLayer { if (!(error instanceof DataRequestAbortError)) { onLoadError(dataRequestId, requestToken, error.message); } + throw error; } } @@ -736,6 +732,7 @@ export class VectorLayer extends AbstractLayer { stopLoading(dataRequestId, requestToken, formatters, nextMeta); } catch (error) { onLoadError(dataRequestId, requestToken, error.message); + throw error; } } @@ -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() {