Skip to content
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

all npm commands hang where outbound traffic to default registry is blocked #2771

Closed
someoneout opened this issue Feb 24, 2021 · 2 comments
Closed
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release

Comments

@someoneout
Copy link

someoneout commented Feb 24, 2021

Current Behavior:

when running npm --help the command will hang. ( I waited over 5 minutes ).

After running strace I discovered that it was attempting to connect to https://registry.npmjs.org/npm. I then attempted to change the registry via npm config set but it also hangs. To resolve my issue I will configure an .npmrc.

Expected Behavior:

at least npm --help and npm config should work without connecting to the internet so a user who might have special firewall restrictions can play around with the cli help and change config settings. Commands can hang for numerous reasons. docker resources, system resources... etc. The last thing I would expect is that its hanging on the registry.

Steps To Reproduce:

Note while troubleshooting this I discovered that if there is a dns failure to the registry npm works as expected. If the registry dns resolves properly but the outbound port is blocked then the bug will appear.

# works ok
echo "registry=https://nodeclishouldnothangforever" >> ~/.npmrc

# should trigger the hanging behavior if dns resolves registry.npmjs.org but fails to connect.  Perhaps sockets stuck in SYN_SENT
echo "registry=https://registry.npmjs.org/npm" >> ~/.npmrc
npm config set registry=https://myregistry.org --verbose
npm verb cli [
npm verb cli   '/usr/local/bin/node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   'config',
npm verb cli   'set',
npm verb cli   'registry=https://myregistry.org',
npm verb cli   '--verbose'
npm verb cli ]
npm info using npm@7.5.3
npm info using node@v15.10.0
npm timing config:load:defaults Completed in 1ms
npm timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 0ms
npm timing config:load:builtin Completed in 0ms
npm timing config:load:cli Completed in 3ms
npm timing config:load:env Completed in 1ms
npm timing config:load:file:/.npmrc Completed in 0ms
npm timing config:load:project Completed in 1ms
npm timing config:load:file:/root/.npmrc Completed in 1ms
npm timing config:load:user Completed in 1ms
npm timing config:load:file:/usr/local/etc/npmrc Completed in 0ms
npm timing config:load:global Completed in 0ms
npm timing config:load:cafile Completed in 0ms
npm timing config:load:validate Completed in 1ms
npm timing config:load:setUserAgent Completed in 0ms
npm timing config:load:setEnvs Completed in 1ms
npm timing config:load Completed in 10ms
npm verb npm-session 60520da2c3d791db
npm timing npm:load Completed in 25ms
[..................] \ : timing npm:load Completed in 25ms

# hanging here ^^^^^^ 

npm --help from a machine with internet access.

npm --help --verbose |& grep registry.npmjs.org
npm http fetch GET 200 https://registry.npmjs.org/npm 2249ms

Environment:

  • OS: docker alpine image. node:15-alpine
  • Node: node@v15.10.0
  • npm: npm@7.5.3
@someoneout someoneout added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Feb 24, 2021
@someoneout someoneout changed the title all npm commands hang indefinitely where outbound traffic to default registry is blocked all npm commands hang where outbound traffic to default registry is blocked Feb 25, 2021
@nlf
Copy link
Contributor

nlf commented Apr 9, 2021

fwiw the registry should be just https://registry.npmjs.org without the path.

if you update to the latest npm (7.9.0 as of now) do you still see this issue? i'm not able to reproduce this, whether blocking traffic to the registry or setting the registry to a host that resolves but doesn't respond.

@darcyclarke darcyclarke removed the Needs Triage needs review for next steps label Apr 16, 2021
@wraithgar
Copy link
Member

The update notifier was running on (almost) all commands, and causing this behavior. That check has been made to be unblocking and this issue should be fixed.

#3348

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

4 participants