Skip to content

Commit

Permalink
[ci-stats-reporter] use a default timeout of 60 seconds (#131428)
Browse files Browse the repository at this point in the history
Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
Spencer and kibanamachine authored May 3, 2022
1 parent 94753e6 commit 06b958d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 6 additions & 1 deletion packages/kbn-ci-stats-reporter/src/ci_stats_reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
11 changes: 8 additions & 3 deletions packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]) => {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1851,7 +1854,8 @@ class CiStatsReporter {
body,
bodyDesc,
path,
query
query,
timeout = 60 * SECOND
}) {
let attempt = 0;
const maxAttempts = 5;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 06b958d

Please sign in to comment.