From c047b6e90500ef7c93b7662ed7ff61aa3cf90ebb Mon Sep 17 00:00:00 2001 From: Spencer Date: Tue, 3 May 2022 11:00:55 -0700 Subject: [PATCH] [ci-stats-reporter] use a default timeout of 60 seconds (#131428) Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> --- .../kbn-ci-stats-reporter/src/ci_stats_reporter.ts | 7 ++++++- packages/kbn-pm/dist/index.js | 11 ++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/kbn-ci-stats-reporter/src/ci_stats_reporter.ts b/packages/kbn-ci-stats-reporter/src/ci_stats_reporter.ts index 73eecbda2ff3e..5d3f17a76f687 100644 --- a/packages/kbn-ci-stats-reporter/src/ci_stats_reporter.ts +++ b/packages/kbn-ci-stats-reporter/src/ci_stats_reporter.ts @@ -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({ auth, body, bodyDesc, path, query }: ReqOptions) { + private async req({ 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; diff --git a/packages/kbn-pm/dist/index.js b/packages/kbn-pm/dist/index.js index b0aabefb1b0f2..6638acfef5ef4 100644 --- a/packages/kbn-pm/dist/index.js +++ b/packages/kbn-pm/dist/index.js @@ -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) {