Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Liza K committed Jul 5, 2020
1 parent 2d10acf commit 6e2180d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/plugins/data/common/search/es_search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import { IKibanaSearchRequest, IKibanaSearchResponse } from '../types';
export const ES_SEARCH_STRATEGY = 'es';

export type ISearchRequestParams = {
body?: any;
index?: string;
trackTotalHits?: boolean;
} & SearchParams;

Expand Down
6 changes: 5 additions & 1 deletion src/plugins/data/common/utils/abort_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ export class AbortError extends Error {
export function toPromise(signal: AbortSignal): Promise<never> {
return new Promise((resolve, reject) => {
if (signal.aborted) reject(new AbortError());
signal.addEventListener('abort', () => reject(new AbortError()));
const abortHandler = () => {
signal.removeEventListener('abort', abortHandler);
reject(new AbortError());
};
signal.addEventListener('abort', abortHandler);
});
}

Expand Down
3 changes: 1 addition & 2 deletions src/plugins/data/public/search/search_interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { BehaviorSubject, throwError, timer, Subscription, defer, from, Observable } from 'rxjs';
import { finalize, filter, catchError } from 'rxjs/operators';
import { finalize, filter } from 'rxjs/operators';
import { ApplicationStart, Toast, ToastsStart, CoreStart } from 'kibana/public';
import { getCombinedSignal, AbortError } from '../../common/utils';
import { IEsSearchRequest, IEsSearchResponse } from '../../common/search';
Expand Down Expand Up @@ -121,7 +121,6 @@ export class SearchInterceptor {
this.pendingCount$.next(++this.pendingCount);

return this.runSearch(request, combinedSignal).pipe(
catchError((e) => throwError(e)),
finalize(() => {
this.pendingCount$.next(--this.pendingCount);
cleanup();
Expand Down

0 comments on commit 6e2180d

Please sign in to comment.