mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
CloudWatch Logs: Adjusts CloudWatch Logs timeout logic (#26621)
* CloudWatch Logs: Adjusts CloudWatch Logs timeout logic Previously CloudWatch Logs queries would time out if, after a number of attempts, a response was received with no additional data. This commit changes the behavior so that a consecutive number of requests yielding no additional data must be made before we cancel the query
This commit is contained in:
@@ -2,8 +2,8 @@ import { from, merge, MonoTypeOperatorFunction, Observable, Subject, Subscriptio
|
||||
import { catchError, filter, map, mergeMap, retryWhen, share, takeUntil, tap, throwIfEmpty } from 'rxjs/operators';
|
||||
import { fromFetch } from 'rxjs/fetch';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { BackendSrv as BackendService, BackendSrvRequest, FetchError, FetchResponse } from '@grafana/runtime';
|
||||
import { AppEvents } from '@grafana/data';
|
||||
import { BackendSrv as BackendService, BackendSrvRequest, FetchResponse, FetchError } from '@grafana/runtime';
|
||||
import { AppEvents, DataQueryErrorType } from '@grafana/data';
|
||||
|
||||
import appEvents from 'app/core/app_events';
|
||||
import config, { getConfig } from 'app/core/config';
|
||||
@@ -341,7 +341,7 @@ export class BackendSrv implements BackendService {
|
||||
// when a request is cancelled by takeUntil it will complete without emitting anything so we use throwIfEmpty to identify this case
|
||||
// in throwIfEmpty we'll then throw an cancelled error and then we'll return the correct result in the catchError or rethrow
|
||||
throwIfEmpty(() => ({
|
||||
cancelled: true,
|
||||
type: DataQueryErrorType.Cancelled,
|
||||
data: null,
|
||||
status: this.HTTP_REQUEST_CANCELED,
|
||||
statusText: 'Request was aborted',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'whatwg-fetch'; // fetch polyfill needed for PhantomJs rendering
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { delay } from 'rxjs/operators';
|
||||
import { AppEvents } from '@grafana/data';
|
||||
import { AppEvents, DataQueryErrorType } from '@grafana/data';
|
||||
|
||||
import { BackendSrv } from '../services/backend_srv';
|
||||
import { Emitter } from '../utils/emitter';
|
||||
@@ -352,7 +352,7 @@ describe('backendSrv', () => {
|
||||
expect(unsubscribe).toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(slowError).toEqual({
|
||||
cancelled: true,
|
||||
type: DataQueryErrorType.Cancelled,
|
||||
data: null,
|
||||
status: -1,
|
||||
statusText: 'Request was aborted',
|
||||
@@ -539,7 +539,7 @@ describe('backendSrv', () => {
|
||||
catchedError = err;
|
||||
}
|
||||
|
||||
expect(catchedError.cancelled).toEqual(true);
|
||||
expect(catchedError.type).toEqual(DataQueryErrorType.Cancelled);
|
||||
expect(catchedError.statusText).toEqual('Request was aborted');
|
||||
expect(unsubscribe).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user