pull/629/head
Rob Herley 2023-12-06 18:31:29 -05:00
parent 043b92bdd5
commit ba1cd59001
No known key found for this signature in database
GPG Key ID: D1602042C3543B06
1 changed files with 10 additions and 15 deletions

25
dist/index.js vendored
View File

@ -5610,7 +5610,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.internalArtifactTwirpClient = void 0; exports.internalArtifactTwirpClient = void 0;
const index_1 = __nccwpck_require__(76308); const http_client_1 = __nccwpck_require__(76308);
const auth_1 = __nccwpck_require__(74548); const auth_1 = __nccwpck_require__(74548);
const core_1 = __nccwpck_require__(66526); const core_1 = __nccwpck_require__(66526);
const generated_1 = __nccwpck_require__(90265); const generated_1 = __nccwpck_require__(90265);
@ -5632,7 +5632,7 @@ class ArtifactHttpClient {
if (retryMultiplier) { if (retryMultiplier) {
this.retryMultiplier = retryMultiplier; this.retryMultiplier = retryMultiplier;
} }
this.httpClient = new index_1.HttpClient(userAgent, [ this.httpClient = new http_client_1.HttpClient(userAgent, [
new auth_1.BearerCredentialHandler(token) new auth_1.BearerCredentialHandler(token)
]); ]);
} }
@ -5646,13 +5646,7 @@ class ArtifactHttpClient {
'Content-Type': contentType 'Content-Type': contentType
}; };
try { try {
// const response = await this.retryableRequest(async () => const { body } = yield this.retryableRequest(() => __awaiter(this, void 0, void 0, function* () { return this.httpClient.post(url, JSON.stringify(data), headers); }));
const response = yield this.httpClient.post(url, JSON.stringify(data), headers);
if (response.message.statusCode !== 200) {
throw new Error(`Non-200: ${response.message.statusCode}`);
}
const body = yield response.readBody();
(0, core_1.debug)(`[Response] ${body}`);
return JSON.parse(body); return JSON.parse(body);
} }
catch (error) { catch (error) {
@ -5668,11 +5662,12 @@ class ArtifactHttpClient {
let isRetryable = false; let isRetryable = false;
try { try {
const response = yield operation(); const response = yield operation();
const body = yield response.readBody();
const statusCode = response.message.statusCode; const statusCode = response.message.statusCode;
(0, core_1.debug)(`[Response] ${response.message.statusCode}`); (0, core_1.debug)(`[Response] ${response.message.statusCode}`);
(0, core_1.debug)(JSON.stringify(response.message.headers, null, 2)); (0, core_1.debug)(JSON.stringify(response.message.headers, null, 2));
if (this.isSuccessStatusCode(statusCode)) { if (this.isSuccessStatusCode(statusCode)) {
return response; return { response, body };
} }
isRetryable = this.isRetryableHttpStatusCode(statusCode); isRetryable = this.isRetryableHttpStatusCode(statusCode);
errorMessage = `Failed request: (${statusCode}) ${response.message.statusMessage}`; errorMessage = `Failed request: (${statusCode}) ${response.message.statusMessage}`;
@ -5704,11 +5699,11 @@ class ArtifactHttpClient {
if (!statusCode) if (!statusCode)
return false; return false;
const retryableStatusCodes = [ const retryableStatusCodes = [
index_1.HttpCodes.BadGateway, http_client_1.HttpCodes.BadGateway,
index_1.HttpCodes.GatewayTimeout, http_client_1.HttpCodes.GatewayTimeout,
index_1.HttpCodes.InternalServerError, http_client_1.HttpCodes.InternalServerError,
index_1.HttpCodes.ServiceUnavailable, http_client_1.HttpCodes.ServiceUnavailable,
index_1.HttpCodes.TooManyRequests, http_client_1.HttpCodes.TooManyRequests,
413 // Payload Too Large 413 // Payload Too Large
]; ];
return retryableStatusCodes.includes(statusCode); return retryableStatusCodes.includes(statusCode);