-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[BUG] npm hangs on gitlab repo install #2741
Comments
@ljharb @darcyclarke @isaacs I would love to help debug this, but I don't know where to start. I looked through the codebase a bit, but couldn't find where this endpoint would be called. If you can point me in the right direction at least, I can try to work on this. |
I'm having the same problem as well, trying to npm install an internal package. |
@nVitius I don't know if this helps you, but what worked for me was to completely uninstall node / npm (I used this as a guide : https://stackoverflow.com/questions/11177954/how-do-i-completely-uninstall-node-js-and-reinstall-from-beginning-mac-os-x), then re-install node using the downloadable package. Hope this helps. |
@dillonbartkus I'm using node/npm with |
@nVitius I picked LTS version, which uses NPM version 6.14.11 |
using 7.6.0, can you try the same command but with |
@nlf that's what The relevant lines are 127-129. Here's a screencap: It looks like this is only happening with Gitlab repos. Installing a Github repo with |
what do you get if you run:
in a shell? does it prompt you for anything? |
if it does, and you accept the prompt, then a follow up additionally, if when you run the
even though we're hiding the line that tells you to press enter, if you press enter the installation will continue. a way to prevent this from happening in the first place would be to
somewhere in your shell profile, which will automatically accept keys that are not in your |
The The npm module is actually installed correctly. The problem is that npm hangs while trying to connect to I'm fairly certain that this is an issue with npm. |
I was able to reproduce it, but the above made the reproduction stop working. I’ll make a repo and test further |
Here is the package.json that I have in that repo:
I don't know if it's relevant, but the repo is under a "Group" in gitlab. |
The group could be very relevant! I’ll do some more testing tomorrow and follow up here |
good news: i can reproduce this issue now! |
ok, i believe i've determined a root cause. what happens is when installing from a known git provider, even when you specify the url via ssh, we attempt to fetch a tarball from that provider first. in the case of gitlab, this redirects to a sign in page with a 503 status code. we see that 503 and interpret it as a failure we can retry, so we apply an exponential backoff and retry again. and then again. this ultimately takes just over a minute. a reasonable workaround would be to add we're discussing whether there's a more permanent fix for this in the cli team |
@nlf thanks for looking into this. I feel that Gitlab should be returning a 401 for these requests instead. A quick search on their issue tracker didn't bring up any existing threads about this; I'll create an issue with them to see if they would be open to that change. Either way, I'll use the Also, could you link to the code that handles this? I wasn't able to find it myself when I was originally looking into the issue. |
thanks for following up with them about that, i tend to agree with you that the 503 they currently respond with isn't the right thing to do, but browser checks are weird critters. i'm hopeful we'll find that they agree and can change it to simplify this for everyone. fetch-retries are handled in the option is assigned to
i'm going to go ahead and close this issue since we have a reasonable workaround for you. thanks again for reaching out to gitlab about this! |
The root cause of this should be fully addressed (and the workaround thus unnecessary) when npm/pacote#65 is landed. |
@nVitius Do you have a link to the issue you made? |
@nlf Wouldn't another fix be to not try and fetch the tarball and instead try the URL that the user actually specified as the first attempt? If I want the tarball I can specify its URL... |
Are there any updates on a possible solution for this issue? I've been facing it for the last few days, using the |
I don't know if this is helpful, but at my company we ended up avoiding this issue by using GitLab's built-in package registries, then instead of specifying the repo URL, we do proper package deployments to the registry and specify namespace + package name. So the issue no longer occurs since we're using packages now instead of git URLs. Perhaps that's a solution you could consider. It's very easy to set up and a lot easier to manage versioning, since you can use actual semver with the packages and all of npm's versioning features. See https://docs.gitlab.com/ee/user/packages/package_registry/ for an overview. We went with the "use a project as a package registry" technique (as opposed to a monorepo) and just have a single project dedicated to being a package registry for everything else. |
@nlf |
Current Behavior:
I am installing a dependency from a private gitlab repo with
git+ssh
. Every time I install it, npm takes a really long time to complete the installation. I ran it with-ddd
and noticed this:Expected Behavior:
npm doesn't try to sign in to gitlab when installing an ssh package
Steps To Reproduce:
npm i --save git+ssh://gitlab.com/some_user/private_repo#master
Environment:
macOS 11.2.1
node 12.20.1
npm 7.5.4
The text was updated successfully, but these errors were encountered: