[ci-stats-reporter] use a default timeout of 60 seconds (#131428)

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Spencer 2022-05-03 11:00:55 -07:00 committed by GitHub
parent 94753e6487
commit 06b958d2a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View file

@ -22,6 +22,8 @@ import { parseConfig, Config, CiStatsMetadata } from '@kbn/ci-stats-core';
import type { CiStatsTestGroupInfo, CiStatsTestRun } from './ci_stats_test_group_types';
const BASE_URL = 'https://ci-stats.kibana.dev';
const SECOND = 1000;
const MINUTE = 60 * SECOND;
function limitMetaStrings(meta: CiStatsMetadata) {
return Object.fromEntries(
@ -107,6 +109,7 @@ interface ReqOptions {
body: any;
bodyDesc: string;
query?: AxiosRequestConfig['params'];
timeout?: number;
}
/** Object that helps report data to the ci-stats service */
@ -282,6 +285,7 @@ export class CiStatsReporter {
},
bodyDesc: `[${group.name}/${group.type}] Chunk of ${bufferBytes} bytes`,
body: buffer.join('\n'),
timeout: 5 * MINUTE,
});
buffer.length = 0;
bufferBytes = 0;
@ -336,7 +340,7 @@ export class CiStatsReporter {
}
}
private async req<T>({ auth, body, bodyDesc, path, query }: ReqOptions) {
private async req<T>({ auth, body, bodyDesc, path, query, timeout = 60 * SECOND }: ReqOptions) {
let attempt = 0;
const maxAttempts = 5;
@ -365,6 +369,7 @@ export class CiStatsReporter {
// if it can be serialized into a string, send it
maxBodyLength: Infinity,
maxContentLength: Infinity,
timeout,
});
return resp.data;

View file

@ -1580,6 +1580,8 @@ var _ciStatsCore = __webpack_require__("../../node_modules/@kbn/ci-stats-core/ta
*/
// @ts-expect-error not "public", but necessary to prevent Jest shimming from breaking things
const BASE_URL = 'https://ci-stats.kibana.dev';
const SECOND = 1000;
const MINUTE = 60 * SECOND;
function limitMetaStrings(meta) {
return Object.fromEntries(Object.entries(meta).map(([key, value]) => {
@ -1782,7 +1784,8 @@ class CiStatsReporter {
groupType: group.type
},
bodyDesc: `[${group.name}/${group.type}] Chunk of ${bufferBytes} bytes`,
body: buffer.join('\n')
body: buffer.join('\n'),
timeout: 5 * MINUTE
});
buffer.length = 0;
bufferBytes = 0;
@ -1851,7 +1854,8 @@ class CiStatsReporter {
body,
bodyDesc,
path,
query
query,
timeout = 60 * SECOND
}) {
let attempt = 0;
const maxAttempts = 5;
@ -1879,7 +1883,8 @@ class CiStatsReporter {
adapter: _http.default,
// if it can be serialized into a string, send it
maxBodyLength: Infinity,
maxContentLength: Infinity
maxContentLength: Infinity,
timeout
});
return resp.data;
} catch (error) {