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
always directly download nupkg and cache the tfms #9230
Conversation
@@ -66,23 +66,31 @@ def project_tfms | |||
end | |||
|
|||
def fetch_package_tfms(dependency_version) | |||
nupkg_buffer = NupkgFetcher.fetch_nupkg_buffer(dependency_urls, dependency.name, dependency_version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only change to this function is wrapping the body in begin
/end
so the result can be cached. No change otherwise.
@@ -111,7 +111,13 @@ def self.fetch_stream(stream_url, auth_header, max_redirects = 5) | |||
current_redirects = 0 | |||
|
|||
loop do | |||
response = fetch_url_with_auth(current_url, auth_header) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fetch_url_with_auth
was caching the result, but apparently repeatedly passing the result to Zip::File.open_buffer()
will result in a corrupted buffer, so the fix is to always download and to not cache anything.
Internal logs were showing
Zip::Error
when trying to unpack the.nupkg
insidecompatibility_checker.rb
. The.nupkg
contents were being cached, but when those contents are passed toZip::File.open_buffer()
the contents were changed which meant that subsequent attempts to open the zip stream might fail because it suddenly wasn't a valid zip archive. The size increase didn't always result in a failure to open the zip, only sometimes. I wasn't able to find any information aboutopen_buffer()
changing the buffer contents/increasing the size.I was able to manually verify this against a test repo (100% repro before the fix, 0% after), but I couldn't figure out why or when to add a unit test and it didn't seem appropriate to check in a binary zip file to this repo. Instead I don't cache the
.nupkg
contents and will always fetch a fresh copy, but do cache the TFM results so in practice this should be the same behavior as before.Since this behavior came out of another bug modifying how we download
.nupkg
contents (see #9204), I decided it would be beneficial to explicitly state what's going on in the downloader with a comment and a direct call to theExcon
download API. This way if the behavior of the previous method ever changes, this functionality won't be broken.