Skip to content

Commit 8ca90b4

Browse files
committed
Revert "[data.search.bsearch] Forward request abortSignal to search strategy (#169041)"
This reverts commit 24fd951.
1 parent 456d980 commit 8ca90b4

4 files changed

Lines changed: 3 additions & 77 deletions

File tree

src/plugins/data/common/search/utils.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ export const isAbortResponse = (response?: IKibanaSearchResponse) => {
2323
/**
2424
* @returns true if request is still running
2525
*/
26-
export const isRunningResponse = (response?: IKibanaSearchResponse) => {
27-
return response?.isRunning ?? false;
28-
};
26+
export const isRunningResponse = (response?: IKibanaSearchResponse) => response?.isRunning ?? false;
2927

3028
export const getUserTimeZone = (
3129
getConfig: AggTypesDependencies['getConfig'],

src/plugins/data/server/search/routes/bsearch.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { catchError } from 'rxjs/operators';
1111
import { BfetchServerSetup } from '@kbn/bfetch-plugin/server';
1212
import type { ExecutionContextSetup } from '@kbn/core/server';
1313
import apm from 'elastic-apm-node';
14-
import { getRequestAbortedSignal } from '../..';
1514
import {
1615
IKibanaSearchRequest,
1716
IKibanaSearchResponse,
@@ -29,7 +28,6 @@ export function registerBsearchRoute(
2928
IKibanaSearchResponse
3029
>('/internal/bsearch', (request) => {
3130
const search = getScoped(request);
32-
const abortSignal = getRequestAbortedSignal(request.events.aborted$);
3331
return {
3432
/**
3533
* @param requestOptions
@@ -41,7 +39,7 @@ export function registerBsearchRoute(
4139
apm.addLabels(executionContextService.getAsLabels());
4240

4341
return firstValueFrom(
44-
search.search(requestData, { ...restOptions, abortSignal }).pipe(
42+
search.search(requestData, restOptions).pipe(
4543
catchError((err) => {
4644
// Re-throw as object, to get attributes passed to the client
4745
// eslint-disable-next-line no-throw-literal

src/plugins/data/server/search/strategies/ese_search/ese_search_strategy.test.ts

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -260,38 +260,6 @@ describe('ES search strategy', () => {
260260

261261
expect(mockApiCaller).toBeCalledTimes(0);
262262
});
263-
264-
it('should delete when aborted', async () => {
265-
mockSubmitCaller.mockResolvedValueOnce({
266-
...mockAsyncResponse,
267-
body: {
268-
...mockAsyncResponse.body,
269-
is_running: true,
270-
},
271-
});
272-
273-
const params = { index: 'logstash-*', body: { query: {} } };
274-
const esSearch = await enhancedEsSearchStrategyProvider(
275-
mockLegacyConfig$,
276-
mockSearchConfig,
277-
mockLogger
278-
);
279-
const abortController = new AbortController();
280-
const abortSignal = abortController.signal;
281-
282-
// Abort after an incomplete first response is returned
283-
setTimeout(() => abortController.abort(), 100);
284-
285-
let err: KbnServerError | undefined;
286-
try {
287-
await esSearch.search({ params }, { abortSignal }, mockDeps).toPromise();
288-
} catch (e) {
289-
err = e;
290-
}
291-
expect(mockSubmitCaller).toBeCalled();
292-
expect(err).not.toBeUndefined();
293-
expect(mockDeleteCaller).toBeCalled();
294-
});
295263
});
296264

297265
describe('with sessionId', () => {
@@ -399,44 +367,6 @@ describe('ES search strategy', () => {
399367
expect(request).toHaveProperty('wait_for_completion_timeout');
400368
expect(request).not.toHaveProperty('keep_alive');
401369
});
402-
403-
it('should not delete a saved session when aborted', async () => {
404-
mockSubmitCaller.mockResolvedValueOnce({
405-
...mockAsyncResponse,
406-
body: {
407-
...mockAsyncResponse.body,
408-
is_running: true,
409-
},
410-
});
411-
412-
const params = { index: 'logstash-*', body: { query: {} } };
413-
const esSearch = await enhancedEsSearchStrategyProvider(
414-
mockLegacyConfig$,
415-
mockSearchConfig,
416-
mockLogger
417-
);
418-
const abortController = new AbortController();
419-
const abortSignal = abortController.signal;
420-
421-
// Abort after an incomplete first response is returned
422-
setTimeout(() => abortController.abort(), 100);
423-
424-
let err: KbnServerError | undefined;
425-
try {
426-
await esSearch
427-
.search(
428-
{ params },
429-
{ abortSignal, sessionId: '1', isSearchStored: true, isStored: true },
430-
mockDeps
431-
)
432-
.toPromise();
433-
} catch (e) {
434-
err = e;
435-
}
436-
expect(mockSubmitCaller).toBeCalled();
437-
expect(err).not.toBeUndefined();
438-
expect(mockDeleteCaller).not.toBeCalled();
439-
});
440370
});
441371

442372
it('throws normalized error if ResponseError is thrown', async () => {

src/plugins/data/server/search/strategies/ese_search/ese_search_strategy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const enhancedEsSearchStrategyProvider = (
8383
};
8484

8585
const cancel = async () => {
86-
if (id && !options.isStored) {
86+
if (id) {
8787
await cancelAsyncSearch(id, esClient);
8888
}
8989
};

0 commit comments

Comments
 (0)