Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Liza K committed Sep 23, 2020
1 parent a9a1715 commit ecd5cce
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/plugins/data/public/search/errors/painless_error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class PainlessError extends KbnError {

super(
i18n.translate('data.painlessError.painlessScriptedFieldErrorMessage', {
defaultMessage: "Error with Painless scripted field '{script}'.",
defaultMessage: "Error executing Painless script: '{script}'.",
values: { script: rootCause?.script },
})
);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/search/search_interceptor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('SearchInterceptor', () => {
}
});

test('Search error should be throttled', async (done) => {
test('Search error should be debounced', async (done) => {
const mockResponse: any = {
result: 500,
body: {
Expand Down
18 changes: 11 additions & 7 deletions src/plugins/data/public/search/search_interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { get, trimEnd, throttle } from 'lodash';
import { get, trimEnd, debounce } from 'lodash';
import { BehaviorSubject, throwError, timer, defer, from, Observable, NEVER } from 'rxjs';
import { catchError, finalize } from 'rxjs/operators';
import { CoreStart, CoreSetup, ToastsSetup } from 'kibana/public';
Expand Down Expand Up @@ -173,12 +173,16 @@ export class SearchInterceptor {
* error notification per session.
* @internal
*/
private showTimeoutError = throttle((e: SearchTimeoutError) => {
this.deps.toasts.addDanger({
title: 'Timed out',
text: toMountPoint(e.getErrorMessage(this.application)),
});
}, 30000);
private showTimeoutError = debounce(
(e: SearchTimeoutError) => {
this.deps.toasts.addDanger({
title: 'Timed out',
text: toMountPoint(e.getErrorMessage(this.application)),
});
},
30000,
{ leading: true, trailing: false }
);

/**
* Searches using the given `search` method. Overrides the `AbortSignal` with one that will abort
Expand Down

0 comments on commit ecd5cce

Please sign in to comment.