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

3.0.5+ hangs when behind a proxy #521

Closed
2 tasks done
geraintwhite opened this issue Mar 21, 2019 · 24 comments
Closed
2 tasks done

3.0.5+ hangs when behind a proxy #521

geraintwhite opened this issue Mar 21, 2019 · 24 comments

Comments

@geraintwhite
Copy link

  • node version: 10.15.1
  • npm version: 6.4.1
  • npm-check-updates version: 3.0.5

On network without proxies set:

$ time npx npm-check-updates@3.0.4 --loglevel verbose
npx: installed 117 in 2.909s
Initializing...
Running in local mode...
Finding package file data...
Using package.json
Fetching latest versions...

 react-native            ^0.55.4  →  ^0.59.1
 react-native-tab-view    ^1.3.2  →   ^2.0.3
 react-navigation        ^2.18.2  →   ^3.5.1
 react-redux              ^5.1.1  →   ^6.0.1
 babel-loader             ^7.1.5  →   ^8.0.5
 babel-preset-react-app   ^3.1.2  →   ^7.0.2
 flow-bin                ^0.67.0  →  ^0.95.1
 jest                    ^23.6.0  →  ^24.5.0

Run ncu -u to upgrade package.json

real    0m15.543s
user    1m7.604s
sys     0m13.357s



$ time npx npm-check-updates@3.0.5 --loglevel verbose
npx: installed 143 in 3.051s
Initializing...
Running in local mode...
Finding package file data...
Using package.json
Fetching latest versions...
[====================] 100%

 react-native            ^0.55.4  →  ^0.59.1
 react-native-tab-view    ^1.3.2  →   ^2.0.3
 react-navigation        ^2.18.2  →   ^3.5.1
 react-redux              ^5.1.1  →   ^6.0.1
 babel-loader             ^7.1.5  →   ^8.0.5
 babel-preset-react-app   ^3.1.2  →   ^7.0.2
 flow-bin                ^0.67.0  →  ^0.95.1
 jest                    ^23.6.0  →  ^24.5.0

Run ncu -u to upgrade package.json

real    0m7.703s
user    0m8.177s
sys     0m2.237s

On network with proxies set:

$ time npx npm-check-updates@3.0.4 --loglevel verbose
npx: installed 117 in 3.08s
Initializing...
Running in local mode...
Finding package file data...
Using package.json
Fetching latest versions...

 react-native            ^0.55.4  →  ^0.59.1
 react-native-tab-view    ^1.3.2  →   ^2.0.3
 react-navigation        ^2.18.2  →   ^3.5.1
 react-redux              ^5.1.1  →   ^6.0.1
 babel-loader             ^7.1.5  →   ^8.0.5
 babel-preset-react-app   ^3.1.2  →   ^7.0.2
 flow-bin                ^0.67.0  →  ^0.95.1
 jest                    ^23.6.0  →  ^24.5.0

Run ncu -u to upgrade package.json

real    0m14.924s
user    1m6.630s
sys     0m12.741s



$ time npx npm-check-updates@3.0.5 --loglevel verbose
npx: installed 143 in 3.552s
Initializing...
Running in local mode...
Finding package file data...
Using /Users/geraintwhite/repos/work/newteam/cloud-voice-app/package.json
Fetching latest versions...
[==========----------] 48%^C

real    1m49.488s
user    0m7.995s
sys     0m2.083s

This appears to be caused by #497 because https://github.com/sindresorhus/package-json doesn't support proxies.

@stoically
Copy link
Collaborator

Yeah, someone would need to try a PR with package-json to add proxy support using rc and tunnel, though it might get rejected.

@stoically
Copy link
Collaborator

Another alternative might be to switch in ncu from package-json to pacote and pass in options parsed by npm-conf.

@raineorshine
Copy link
Owner

I agree that it is unlikely that proxy support will be added to package-json. If there is an alternative package manifest fetcher that supports proxies that would be the way to go. If that doesn't work, we can always have a fallback to the v3.0.0 spawn npm approach, but that is very slow.

@oupala
Copy link

oupala commented Mar 25, 2019

I have the same problem because I'm behind a proxy.

The stange thing is that ncu 2.15.0 works well behind a proxy while 3.1.1 does not.

Is there a regression somewhere?

@geraintwhite
Copy link
Author

@oupala yes, it was caused by the addition of package-json in #497.

@stoically
Copy link
Collaborator

stoically commented Mar 25, 2019

@oupala @grit96 There's an open PR #523 to add proxy support. Could you confirm that ncu works for you with that patch? npx npm-check-updates@stoically/npm-check-updates#proxy

@geraintwhite
Copy link
Author

@stoically can confirm it works for me. If, like me, you can't use git+ssh behind your proxy, run npx git+https://github.com/stoically/npm-check-updates.git#proxy.

@oupala
Copy link

oupala commented Mar 25, 2019

@stoically I typed the command you wrote (npx npm-check-updates@stoically/npm-check-updates#proxy) and I had a successful execution. So I think I validate the fix.

@raineorshine
Copy link
Owner

Thank you @stoically! Merged and published in v.3.1.2.

@oupala
Copy link

oupala commented Mar 27, 2019

It works like a charm!

@Nowheresly
Copy link

We're still having issues with our corporate proxy with version v.3.1.2:
Here is an example of our settings:

http_proxy=http://our.corporate.proxy:8080
no_proxy=our.internal.domain
registry_url=http://our.internal.domain/repository/npmjs

We are using a corporate proxy for all requests except those for our internal npm registry.
It seems the version v.3.1.2 does not take into account the no_proxy setting.

@stoically
Copy link
Collaborator

@Nowheresly 3.1.3 got released which should handle that case.

@mlc-mlapis
Copy link

@stoically ... hmm, still some problems with proxy even on version 3.1.3. When running as ncu it does nothing - a black new line with no message / no error ...

Setting like:

https_proxy=http://proxy.xxx.yyy.ccc:8080
http_proxy=http://proxy.xxx.yyy.ccc:8080
no_proxy=localhost

NodeJS: 11.13.0
NPM: 6.7.0
Windows 10 (1809)

@stoically
Copy link
Collaborator

@mlc-mlapis Are you sure it's proxy related and not #136? Try running ncu --packageFile package.json?

@mlc-mlapis
Copy link

@stoically ... hmm, not sure but when running:

ncu --loglevel verbose --packageFile package.json

only the output is: Initializing... and then nothing and I have to break it via CTRL+C.

@mlc-mlapis
Copy link

mlc-mlapis commented Mar 29, 2019

@stoically ... actually, I am not sure when the problem started ... but it's not so long when it appeared after some upgrade.

@stoically
Copy link
Collaborator

stoically commented Mar 29, 2019

@mlc-mlapis Interesting. That means it hangs between Initializing and the call to findPackage which should log Running in local mode. What happens in your shell when you execute npm.cmd config get prefix? Also, which shell are you using (cmd.exe, cygwin bash, ..)?

@mlc-mlapis
Copy link

mlc-mlapis commented Mar 29, 2019

@stoically ... running npm.cmd config get prefix returns C:\Program Files\nodejs ... the directory, where NodeJS is installed. The result is the same for CMD or PowerShell or Cygwin.

@stoically
Copy link
Collaborator

stoically commented Mar 29, 2019

@mlc-mlapis Mysterious. Could you try npx npm-check-updates@stoically/npm-check-updates#winlog --prefix="%AppData%\npm" --packageFile=package.json --loglevel=verbose? We should probably move into a new issue too, since this isn't proxy-related.

@Nowheresly
Copy link

@Nowheresly 3.1.3 got released which should handle that case.

I confirm, the problem is fixed with version 3.1.3. Thanks @stoically !!

@mlc-mlapis
Copy link

mlc-mlapis commented Apr 1, 2019

@stoically ... I tried to install as you required:

npx npm-check-updates@stoically/npm-check-updates#winlog --prefix="%AppData%\npm" --packageFile=package.json --loglevel=verbose

The result was:

[..................] / rollbackFailedOptional: verb npm-session b1fd01e6005c78ec
...
[############......] / extract:lodash: sill extract lodash@^4.17.11 extracted to C:\Users\...\AppData\Roaming\npm-cache\_npx\13620\node_modules\.staging\lodash-c6a62b56 (911ms)
...
npx: installed 154 za 97.857s
Initializing...
Running in local mode...
Finding package file data...
Checking C:\Data\...\package.json
Fetching latest versions...
[====================] 38/38 100%
typescript  3.2.4  →  3.4.1

As you can see the time, it was 98 seconds and the 90 seconds of waiting was on the beginning after the line [..................] / rollbackFailedOptional: verb npm-session b1fd01e6005c78ec, which was showed immediately.

Previously I never waited so long and I was breaking the process before it prints anything on the console.

So be aware that the problem could be related to some problems with accessing some NPM servers, I tried to run and waited for the task to finish and the result was:

The time to finish was 194 seconds.

npm-check-updates
[INFO]: You can also use ncu as an alias
Checking C:\Data\...\package.json
[====================] 38/38 100%
 typescript  3.2.4  →  3.4.1

So it really looks like some NPM servers are not accessible from our environment (but they were) and the process is waiting for a connection and then switches to another NPM server on a timeout.

Not sure why this happens right now ... because of global install takes just 10 seconds:

npm i -g npm-check-updates
C:\Program Files\nodejs\npm-check-updates -> C:\Program Files\nodejs\node_modules\npm-check-updates\bin\npm-check-updates
C:\Program Files\nodejs\ncu -> C:\Program Files\nodejs\node_modules\npm-check-updates\bin\ncu
+ npm-check-updates@3.1.3
updated 3 packages in 10.833s

Maybe some message with more detailed info which NPM server is accessed ... with countdown time ... and switching to the alternative NPM server on a time-out would be helpful for understanding what happened.

@stoically
Copy link
Collaborator

@mlc-mlapis So if I understand you correct, ncu now works, but just takes a long time?

@mlc-mlapis
Copy link

@stoically ... yep, exactly. After running ncu it takes 3 minutes to show anything ... after that, it runs as usual during 10 seconds. Really not clear what blocks the process. Do you think that it's really waiting for a connection and after the time-out, it switches to another NPM server?

@stoically
Copy link
Collaborator

@mlc-mlapis ncu uses got under the hood, which automatically retries 2 times if a request fails. If the request would fail after that, you would see an exception thrown from ncu. There's no logic to switch the npm registry, it'll always use the default one, or the one configured in .npmrc or env variables. npm and ncu should use the same registry - maybe check netstat to see where they connect to?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants