Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception "Aborted" when downloading tools from GitHub releases #194

Open
piraces opened this issue Apr 9, 2023 · 11 comments
Open

Exception "Aborted" when downloading tools from GitHub releases #194

piraces opened this issue Apr 9, 2023 · 11 comments
Labels

Comments

@piraces
Copy link

piraces commented Apr 9, 2023

Since the change introduced in #189 , I have been observing that downloading from GitHub releases directly produces an "Aborted" exception but the binary just seems to be fine... I'm using Node 16.x,

For example when downloading Azure Bicep it produces the following output:

Downloading: https://github.com/Azure/bicep/releases/download/v0.16.1/bicep-osx-x64
##[error]Aborted
##[warning]Content-Length (57479424 bytes) did not match downloaded file size (57435840 bytes).

With version 2.0.2 of this library the warning about Content-Length is not shown and the binary it's always fine...

Sample correct execution on version 2.0.2: https://raulejea.visualstudio.com/Bicep%20Tasks/_build/results?buildId=378&view=logs&j=295e7618-5d04-5731-f417-e49cf049e2b1&t=99b7bc6e-aa6b-56e3-8d64-dbce029ad954

Failing execution on version 2.0.4: https://raulejea.visualstudio.com/Bicep%20Tasks/_build/results?buildId=376&view=logs&j=295e7618-5d04-5731-f417-e49cf049e2b1&t=99b7bc6e-aa6b-56e3-8d64-dbce029ad954

The related extension: https://github.com/piraces/azure-devops-bicep-task

It's GitHub that it's currently aborting the request of could be another type of error?
Please let me know if you need more information about this behaviour.
Thanks!

@lsynopsys
Copy link

We are also facing the same issue
I found the issue on file node_modules/azure-pipelines-tool-lib/tool.js where the code trying to match the downloaded file size and the size from headers 'Content-Length'. The issue is Response header's Content-Length differs from the actual size of the file as it may contain the next message details or response body.

if (!isNaN(downloadedContentLength) &&
                        !isNaN(fileSizeInBytes) &&
                        fileSizeInBytes !== downloadedContentLength) {
                        tl.warning(`Content-Length (${downloadedContentLength} bytes) did not match downloaded file size (${fileSizeInBytes} bytes).`);
                    }

Please let us know if there is any fix for this soon.

Thanks.

@DenisRumyantsev
Copy link
Contributor

@piraces @lsynopsys thanks for reporting this issue, let us take a look at it

@sergey-koryshev
Copy link
Contributor

sergey-koryshev commented May 5, 2023

@piraces, @lsynopsys, could you please provide some demo script to reproduce the issue? On my side it works as expected:

const tool = require('azure-pipelines-tool-lib');
async function main() {
    await tool.downloadTool('https://github.com/Azure/bicep/releases/download/v0.16.1/bicep-osx-x64');
}
main();
Downloading: https://github.com/Azure/bicep/releases/download/v0.16.1/bicep-osx-x64
##vso[task.debug]destination temp\1fc2ab87-0f18-484b-8aae-c5811cf48a22
##vso[task.debug]downloading
##vso[task.debug]Content-Length of downloaded file: 57479424
##vso[task.debug]creating stream
##vso[task.debug]download complete
##vso[task.debug]Downloaded file size: 57479424 bytes

Error Aborted means that request was aborted by target server. Maybe it throttles your requests or there is some maintenance process due to some outage.

@xlight05
Copy link

xlight05 commented Jun 18, 2023

Having the same issue. Are there any best practices for hosting these downloadable artifacts to avoid such issues?

@lsynopsys
Copy link

lsynopsys commented Jun 19, 2023

Downgrade the version to "azure-pipelines-tool-lib": "^2.0.2", until the azure team fixes this issue.

@lsynopsys
Copy link

lsynopsys commented Aug 25, 2023

It is happening once again on cloud and self-hosted runners and this time with "azure-pipelines-tool-lib": "^2.0.2" as well, Do we have any fix?

@sergey-koryshev
Copy link
Contributor

@lsynopsys the issue I believe comes from the server you download file from. You need to escalate it to server owners and figure out why it throttles your requests. To mitigate your issues you can add retries to your code or use agent image (or use docker-image) with pre-installed tool you try to download

@henryd24
Copy link

henryd24 commented Nov 6, 2023

@sergey-koryshev It does not seem to be a problem of the server where it is downloading, because I have the same problem, and apparently are the agents hosted by azure, because with a self hosted agent works, doing the local test, it works, but when I change the pool to an agent hosted by azure, it comes out the error "Aborted" because apparently the connection stream is closed when writing the file. I have implemented in the code controls for retries and timeouts.

Agent version in both 3.227.2

Self Hosted Agent
image

Azure Hosted Agent
image

@lsynopsys
Copy link

@sergey-koryshev event aborted when the file is open state is causing the issue for us https://github.com/microsoft/azure-pipelines-tool-lib/blob/master/tool.ts#L261

@henryd24 We have also observed the same issue, For the time being, we have removed the aborted state by importing tool.ts file into our repo.

@henryd24
Copy link

henryd24 commented Nov 6, 2023

@lsynopsys yeah, doing what you said worked without any problem, thank you very much. I hope they fix this problem soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants