mirror of https://github.com/actions/toolkit
Merge pull request #1596 from actions/robherley/cleanup-handlers
Cleanup artifact handlers hanging node processpull/1598/head
commit
43ccaf05d9
|
@ -59,10 +59,10 @@ class ArtifactHttpClient implements Rpc {
|
||||||
'Content-Type': contentType
|
'Content-Type': contentType
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const response = await this.retryableRequest(async () =>
|
const {body} = await this.retryableRequest(async () =>
|
||||||
this.httpClient.post(url, JSON.stringify(data), headers)
|
this.httpClient.post(url, JSON.stringify(data), headers)
|
||||||
)
|
)
|
||||||
const body = await response.readBody()
|
|
||||||
return JSON.parse(body)
|
return JSON.parse(body)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(`Failed to ${method}: ${error.message}`)
|
throw new Error(`Failed to ${method}: ${error.message}`)
|
||||||
|
@ -71,7 +71,7 @@ class ArtifactHttpClient implements Rpc {
|
||||||
|
|
||||||
async retryableRequest(
|
async retryableRequest(
|
||||||
operation: () => Promise<HttpClientResponse>
|
operation: () => Promise<HttpClientResponse>
|
||||||
): Promise<HttpClientResponse> {
|
): Promise<{response: HttpClientResponse; body: string}> {
|
||||||
let attempt = 0
|
let attempt = 0
|
||||||
let errorMessage = ''
|
let errorMessage = ''
|
||||||
while (attempt < this.maxAttempts) {
|
while (attempt < this.maxAttempts) {
|
||||||
|
@ -80,11 +80,13 @@ class ArtifactHttpClient implements Rpc {
|
||||||
try {
|
try {
|
||||||
const response = await operation()
|
const response = await operation()
|
||||||
const statusCode = response.message.statusCode
|
const statusCode = response.message.statusCode
|
||||||
debug(`[Response] ${response.message.statusCode}`)
|
const body = await response.readBody()
|
||||||
debug(JSON.stringify(response.message.headers, null, 2))
|
debug(`[Response] - ${response.message.statusCode}`)
|
||||||
|
debug(`Headers: ${JSON.stringify(response.message.headers, null, 2)}`)
|
||||||
|
debug(`Body: ${body}`)
|
||||||
|
|
||||||
if (this.isSuccessStatusCode(statusCode)) {
|
if (this.isSuccessStatusCode(statusCode)) {
|
||||||
return response
|
return {response, body}
|
||||||
}
|
}
|
||||||
|
|
||||||
isRetryable = this.isRetryableHttpStatusCode(statusCode)
|
isRetryable = this.isRetryableHttpStatusCode(statusCode)
|
||||||
|
|
|
@ -40,11 +40,6 @@ export async function uploadArtifact(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const zipUploadStream = await createZipUploadStream(
|
|
||||||
zipSpecification,
|
|
||||||
options?.compressionLevel
|
|
||||||
)
|
|
||||||
|
|
||||||
// get the IDs needed for the artifact creation
|
// get the IDs needed for the artifact creation
|
||||||
const backendIds = getBackendIdsFromToken()
|
const backendIds = getBackendIdsFromToken()
|
||||||
|
|
||||||
|
@ -73,6 +68,11 @@ export async function uploadArtifact(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const zipUploadStream = await createZipUploadStream(
|
||||||
|
zipSpecification,
|
||||||
|
options?.compressionLevel
|
||||||
|
)
|
||||||
|
|
||||||
// Upload zip to blob storage
|
// Upload zip to blob storage
|
||||||
const uploadResult = await uploadZipToBlobStorage(
|
const uploadResult = await uploadZipToBlobStorage(
|
||||||
createArtifactResp.signedUploadUrl,
|
createArtifactResp.signedUploadUrl,
|
||||||
|
|
Loading…
Reference in New Issue