1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/upload-artifact.git synced 2024-11-08 18:32:40 +00:00
This commit is contained in:
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

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