Skip to content

Adds socket timeout and validate file size - #269

Merged
dhadka merged 3 commits into
masterfrom
socket-timeout
Apr 29, 2020
Merged

dhadka merged 3 commits into
masterfrom
socket-timeout

Conversation

@dhadka

@dhadka dhadka commented Apr 22, 2020 •

Copy link
Copy Markdown
Contributor

Adds socket timeout of 5 seconds and validates file size.

Recent network issues between the Actions runner and cache storage have caused flakiness in download speeds. While debugging, we observed periods where no traffic was received over the socket. In some cases, no traffic is received but the socket remains open for many minutes. Furthermore, if the socket closes before all content is received, the cache action incorrectly proceeds to untar the file, causing an "unexpected end of file" error.

This PR sets a socket timeout of 5 seconds. As a result, if there is a period were no traffic is received for 5 seconds, the download will abort and will be treated as a cache miss. Additionally, the downloaded file size is compared against the expected content length, if provided.

@joshmgross joshmgross left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I left some clarifying questions

Comment thread src/cacheHttpClient.ts Resolved
Comment thread src/cacheHttpClient.ts Resolved
Comment thread src/constants.ts Resolved
@munrocket

Copy link
Copy Markdown

Nice work! Hope that this will be merged.

Comment thread src/constants.ts

export const CacheFilename = "cache.tgz";

export const SocketTimeout = 5000;

@aiqiaoy aiqiaoy Apr 28, 2020 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: SocketTimeoutInMs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comment with details.

Comment thread src/cacheHttpClient.ts Resolved
@dhadka
dhadka merged commit 54626c4 into master Apr 29, 2020
@munrocket

Copy link
Copy Markdown

Ty!

@joshmgross
joshmgross deleted the socket-timeout branch April 29, 2020 18:32
@munrocket

Copy link
Copy Markdown

Validation is work #271. So to finally fix this problem we need to wrap warning: exit code 2 and try to download cache again, as it was done in actions/setup-node#116

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants