Skip to content

Commit ecd5cce

Browse files
author
Liza K
committed
code review
1 parent a9a1715 commit ecd5cce

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

src/plugins/data/public/search/errors/painless_error.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class PainlessError extends KbnError {
3333

3434
super(
3535
i18n.translate('data.painlessError.painlessScriptedFieldErrorMessage', {
36-
defaultMessage: "Error with Painless scripted field '{script}'.",
36+
defaultMessage: "Error executing Painless script: '{script}'.",
3737
values: { script: rootCause?.script },
3838
})
3939
);

src/plugins/data/public/search/search_interceptor.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe('SearchInterceptor', () => {
9191
}
9292
});
9393

94-
test('Search error should be throttled', async (done) => {
94+
test('Search error should be debounced', async (done) => {
9595
const mockResponse: any = {
9696
result: 500,
9797
body: {

src/plugins/data/public/search/search_interceptor.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
import { get, trimEnd, throttle } from 'lodash';
20+
import { get, trimEnd, debounce } from 'lodash';
2121
import { BehaviorSubject, throwError, timer, defer, from, Observable, NEVER } from 'rxjs';
2222
import { catchError, finalize } from 'rxjs/operators';
2323
import { CoreStart, CoreSetup, ToastsSetup } from 'kibana/public';
@@ -173,12 +173,16 @@ export class SearchInterceptor {
173173
* error notification per session.
174174
* @internal
175175
*/
176-
private showTimeoutError = throttle((e: SearchTimeoutError) => {
177-
this.deps.toasts.addDanger({
178-
title: 'Timed out',
179-
text: toMountPoint(e.getErrorMessage(this.application)),
180-
});
181-
}, 30000);
176+
private showTimeoutError = debounce(
177+
(e: SearchTimeoutError) => {
178+
this.deps.toasts.addDanger({
179+
title: 'Timed out',
180+
text: toMountPoint(e.getErrorMessage(this.application)),
181+
});
182+
},
183+
30000,
184+
{ leading: true, trailing: false }
185+
);
182186

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

0 commit comments

Comments
 (0)