Use content hash vs. freshness in publish registry#498
Open
jablko wants to merge 1 commit intomicrosoft:mainfrom
Open
Use content hash vs. freshness in publish registry#498jablko wants to merge 1 commit intomicrosoft:mainfrom
jablko wants to merge 1 commit intomicrosoft:mainfrom
Conversation
37617ac to
33bb063
Compare
sandersn
requested changes
Jul 15, 2022
Member
sandersn
left a comment
There was a problem hiding this comment.
Compared to the retag script, how many accesses to npm do you expect this will save? I didn't think that many were happening on an average run.
The fact that this code is in the retag script already is a good argument for copying it here -- but I'd like a good way to test that this is working. I guess deploying and watching a publish or two is one way, but is there some pattern of usage that would empty a lot of the cache and make it obvious that it is correctly deciding when to re-download from npm? I want to be confident of this change since it could cause subtle problems if it's wrong.
| import assert = require("assert"); | ||
| import process from "process"; | ||
| import { emptyDir } from "fs-extra"; | ||
| // @ts-expect-error |
| pickManifest(offline, `~${typing.major}.${typing.minor}`).typesPublisherContentHash === typing.contentHash | ||
| ) | ||
| return offline; | ||
| // @ts-expect-error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Same as the calculate versions and retag scripts, when gathering npm metadata, always revalidate if the content hashes differ (fresh or not) and never revalidate if they match (stale or not). This will use the cache for types that haven't changed since the last run, hitting the origin (npm registry) less often. If we have the content hash from the DT repo and the cached metadata, we might as well use them.