-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Loading upstream tarball doesn't respect package.proxy array #1642
Comments
In the config above, every package (denoted by |
That's what I would expect. But it doesn't 😄 |
Its the for loop - it doesn't exit at the first resolution, like you mentioned @Beanow - maybe the "workaround" is to have the one you really want to be last in the array? |
Try setting a specific package (like 'react') to be taken from cachednpm and other without cache. Then, paste results and check if the storage contains cached package. |
I've hacked in a log (in console.log('DECIDED ON UPLINK:', uplink.upname); This outputs |
Did you mean something like this @sergiohgz? uplinks:
cachednpm:
url: https://registry.npmjs.org/
cache: true
npmjs:
url: https://registry.npmjs.org/
cache: false
packages:
'statuses':
access: $all
proxy: cachednpm
'**':
access: $all
proxy: npmjs
|
I cannot reproduce the issue, let me investigate deeper, it's working as expected. |
It will always select the last one with a matching URL, so it won't let you use different settings for different packages that way. |
Well, I understand your thoughts, and that's correct, the loop is not intended to stop if it find several urls that matches the uplink selected, so it will get latest uplink. I'm going to make a PR with the fix soon 😉 On the other hand, we didn't evaluate the need for setting the same URL for different uplink definitions. Why would you want to do that? (pure curiosity 😃) |
Well, as the example shows, the uplink definition includes some configuration like For example, some should cache while others shouldn't. The particular use-case I'm thinking of, is to provide a redundant host for our own packages when you're hitting a firewall for the major registries. To preserve disk-space it should proxy (but not cache) |
- if (self.uplinks[uplinkId].isUplinkValid(file.url)) {
+ if (hasProxyTo(name, uplinkId, self.config.packages)) { This change works for me. Though should probably add a unit test to prove. |
* test: different uplinks with the same URL This test reproduces #1642 * fix: use hasProxyTo to find correct uplink for tarballs Fixes #1642 Co-authored-by: Juan Picado @jotadeveloper <juanpicado19@gmail.com>
🤖This thread has been automatically locked 🔒 since there has not been any recent activity after it was closed. |
Describe the bug
Having multiple uplinks point to the same registry, the package.proxy array gets ignored.
Instead we'll walk through the uplinks and select the last one in the list that can serve the URL we've found for our upstream tarball.
To Reproduce
http://localhost:4873/@verdaccio/streams/-/streams-8.5.2.tgz
./storage/@verdaccio/streams/streams-8.5.2.tgz
does not existThe uplink chosen here was
npmjs
, notcachednpm
.Expected behavior
Making the upstream request should respect the packages.proxy array.
In this example, selecting
cachednpm
for it's uplink, causing it to cache the tarball.Environment information
Additional context
I believe the culprit here is:
verdaccio/src/lib/storage.ts
Lines 207 to 211 in 32aabca
The
isUplinkValid
check will be true for both uplinks. So the last one in the array will be selected.Perhaps it should be using
hasProxyTo
fromsrc/lib/config-utils.ts
?The text was updated successfully, but these errors were encountered: