Skip to content

Commit

Permalink
Abort after 2mins
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed Oct 17, 2023
1 parent 7e9ae73 commit 7b06ea5
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ export const esqlSearchStrategyProvider = (
* @returns `Observable<IEsSearchResponse<any>>`
*/
search: (request, { abortSignal, ...options }, { esClient, uiSettingsClient }) => {
const abortController = new AbortController();
// We found out that there are cases where we are not aborting correctly
// For this reasons we want to manually cancel he abort signal after 2 mins

abortSignal?.addEventListener('abort', () => {
abortController.abort();
});

// Also abort after two mins
setTimeout(() => abortController.abort(), ES_TIMEOUT_IN_MS);

// Only default index pattern type is supported here.
// See ese for other type support.
if (request.indexType) {
Expand All @@ -43,12 +54,9 @@ export const esqlSearchStrategyProvider = (
},
},
{
signal: abortSignal,
signal: abortController.signal,
meta: true,
// this is a temporary solution for ES|QL queries.
// we found out that they are not aborted correctly
// so we change the ES timeout to 2mins
// and remove the retries
// we don't want the ES client to retry (default value is 3)
maxRetries: 0,
requestTimeout: ES_TIMEOUT_IN_MS,
}
Expand Down

0 comments on commit 7b06ea5

Please sign in to comment.