Skip to content

Commit

Permalink
Fixing abort error on dashboard (elastic#61279)
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar committed Mar 26, 2020
1 parent b9e6ed4 commit d9d725f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export class VisualizeEmbeddable extends Embeddable<VisualizeInput, VisualizeOut
private domNode: any;
public readonly type = VISUALIZE_EMBEDDABLE_TYPE;
private autoRefreshFetchSubscription: Subscription;
private abortController?: AbortController;

constructor(
timefilter: TimefilterContract,
Expand Down Expand Up @@ -327,9 +328,14 @@ export class VisualizeEmbeddable extends Embeddable<VisualizeInput, VisualizeOut
},
uiState: this.vis.uiState,
};
if (this.abortController) {
this.abortController.abort();
}
this.abortController = new AbortController();
this.expression = await buildPipeline(this.vis, {
timefilter: this.timefilter,
timeRange: this.timeRange,
abortSignal: this.abortController!.signal,
});

if (this.handler) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ export const buildPipeline = async (
params: {
timefilter: TimefilterContract;
timeRange?: any;
abortSignal?: AbortSignal;
}
) => {
const { indexPattern, searchSource } = vis.data;
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/expressions/public/render_error_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export const renderErrorHandler: RenderErrorHandlerFnType = (
error: RenderError,
handlers: IInterpreterRenderHandlers
) => {
if (error.name === 'AbortError') {
handlers.done();
return;
}

getNotifications().toasts.addError(error, {
title: i18n.translate('expressions.defaultErrorRenderer.errorTitle', {
defaultMessage: 'Error in visualisation',
Expand Down

0 comments on commit d9d725f

Please sign in to comment.