lensapp / lens

Lens - The way the world runs Kubernetes
https://k8slens.dev/
MIT License
22.55k stars 1.47k forks source link

npm does not use proxy by default #4369

Open vbskruger opened 2 years ago

vbskruger commented 2 years ago

Describe the bug Lens uses npm to load the dependencies of the default extensions (i.e. pod-menu). However, if you are behind a company proxy, and you define the proxy settings in the preferences --> proxy page, it seems npm ignores it, leading to a timeout in the connection and not installing the dependencies.

To Reproduce Steps to reproduce the behavior:

  1. Be behind a company proxy
  2. Run lens
  3. Wait for an error message with a timeout
55 error code ETIMEDOUT
56 error errno ETIMEDOUT
57 error network request to https://registry.npmjs.org/react-open-doodles failed, reason: connect ETIMEDOUT 104.16.27.35:443
58 error network This is a problem related to network connectivity.
58 error network In most cases you are behind a proxy or have bad network settings.
58 error network
58 error network If you are behind a proxy, please make sure that the
58 error network 'proxy' config is set properly.  See: 'npm help config'

Expected behavior Lens should load the dependencies of the extensions using the defined proxy settings.

Environment (please complete the following information):

Logs:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Users\\user\\AppData\\Local\\Programs\\kontena-lens\\Lens.exe',
1 verbose cli   'C:\\Users\\user\\AppData\\Local\\Programs\\kontena-lens\\resources\\app.asar\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   '--no-audit',
1 verbose cli   '--only=prod',
1 verbose cli   '--prefer-offline',
1 verbose cli   '--no-package-lock'
1 verbose cli ]
2 info using npm@6.14.13
3 info using node@v14.16.0
4 verbose npm-session 0dafaa0dbd852da2
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall Lens
7 info lifecycle @~preinstall: @
8 silly install loadCurrentTree
9 silly install readLocalPackageData
10 timing stage:loadCurrentTree Completed in 30ms
11 silly install loadIdealTree
12 silly install cloneCurrentTreeToIdealTree
13 timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms
14 silly install loadShrinkwrap
15 timing stage:loadIdealTree:loadShrinkwrap Completed in 3ms
16 silly install loadAllDepsIntoIdealTree
17 silly pacote directory manifest for example-extension@file:C:/Users/user/AppData/Local/Programs/kontena-lens/resources/extensions/example-extension fetched in 71ms
18 silly pacote directory manifest for lenscloud-lens-extension@file:C:/Users/user/AppData/Local/Programs/kontena-lens/resources/extensions/lenscloud-lens-extension fetched in 47ms
19 silly pacote directory manifest for lens-support-page@file:C:/Users/user/AppData/Local/Programs/kontena-lens/resources/extensions/support-page fetched in 46ms
20 silly resolveWithNewModule example-extension@1.0.0 checking installable status
21 silly resolveWithNewModule lenscloud-lens-extension@5.2.5-latest.20211001.2 checking installable status
22 silly resolveWithNewModule lens-support-page@0.1.0 checking installable status
23 silly pacote file manifest for lens-metrics-cluster-feature@file:C:/Users/user/AppData/Local/Programs/kontena-lens/resources/extensions/metrics-cluster-feature/lens-metrics-cluster-feature-5.2.5-latest.20211001.2.tgz fetched in 247ms
24 silly resolveWithNewModule lens-metrics-cluster-feature@5.2.5-latest.20211001.2 checking installable status
25 silly removeObsoleteDep removing lens-metrics-cluster-feature@5.2.5-latest.20211001.2 from the tree as its been replaced by a newer version or is no longer required
26 silly pacote file manifest for lens-pod-menu@file:C:/Users/user/AppData/Local/Programs/kontena-lens/resources/extensions/pod-menu/lens-pod-menu-5.2.5-latest.20211001.2.tgz fetched in 250ms
27 silly resolveWithNewModule lens-pod-menu@5.2.5-latest.20211001.2 checking installable status
28 silly removeObsoleteDep removing lens-pod-menu@5.2.5-latest.20211001.2 from the tree as its been replaced by a newer version or is no longer required
29 silly pacote file manifest for lens-node-menu@file:C:/Users/user/AppData/Local/Programs/kontena-lens/resources/extensions/node-menu/lens-node-menu-5.2.5-latest.20211001.2.tgz fetched in 255ms
30 silly resolveWithNewModule lens-node-menu@5.2.5-latest.20211001.2 checking installable status
31 silly removeObsoleteDep removing lens-node-menu@5.2.5-latest.20211001.2 from the tree as its been replaced by a newer version or is no longer required
32 silly pacote file manifest for lens-survey@file:C:/Users/user/AppData/Local/Programs/kontena-lens/resources/extensions/survey/lens-survey-5.2.5-latest.20211001.2.tgz fetched in 256ms
33 silly resolveWithNewModule lens-survey@5.2.5-latest.20211001.2 checking installable status
34 silly removeObsoleteDep removing lens-survey@5.2.5-latest.20211001.2 from the tree as its been replaced by a newer version or is no longer required
35 silly pacote file manifest for lens-license@file:C:/Users/user/AppData/Local/Programs/kontena-lens/resources/extensions/license-menu-item/lens-license-5.2.5-latest.20211001.2.tgz fetched in 257ms
36 silly resolveWithNewModule lens-license@5.2.5-latest.20211001.2 checking installable status
37 silly removeObsoleteDep removing lens-license@5.2.5-latest.20211001.2 from the tree as its been replaced by a newer version or is no longer required
38 silly pacote file manifest for kube-object-event-status@file:C:/Users/user/AppData/Local/Programs/kontena-lens/resources/extensions/kube-object-event-status/kube-object-event-status-5.2.5-latest.20211001.2.tgz fetched in 263ms
39 silly resolveWithNewModule kube-object-event-status@5.2.5-latest.20211001.2 checking installable status
40 silly removeObsoleteDep removing kube-object-event-status@5.2.5-latest.20211001.2 from the tree as its been replaced by a newer version or is no longer required
41 silly pacote file manifest for lens-telemetry@file:C:/Users/user/AppData/Local/Programs/kontena-lens/resources/extensions/telemetry/lens-telemetry-5.2.5-latest.20211001.2.tgz fetched in 272ms
42 silly resolveWithNewModule lens-telemetry@5.2.5-latest.20211001.2 checking installable status
43 silly removeObsoleteDep removing lens-telemetry@5.2.5-latest.20211001.2 from the tree as its been replaced by a newer version or is no longer required
44 silly fetchPackageMetaData error for react-open-doodles@^1.0.5 request to https://registry.npmjs.org/react-open-doodles failed, reason: connect ETIMEDOUT 104.16.27.35:443
45 timing stage:rollbackFailedOptional Completed in 0ms
46 timing stage:runTopLevelLifecycles Completed in 133560ms
47 silly saveTree Lens
47 silly saveTree +-- example-extension@1.0.0
47 silly saveTree +-- kube-object-event-status@5.2.5-latest.20211001.2
47 silly saveTree +-- lens-license@5.2.5-latest.20211001.2
47 silly saveTree +-- lens-metrics-cluster-feature@5.2.5-latest.20211001.2
47 silly saveTree +-- lens-node-menu@5.2.5-latest.20211001.2
47 silly saveTree +-- lens-pod-menu@5.2.5-latest.20211001.2
47 silly saveTree +-- lens-support-page@0.1.0
47 silly saveTree +-- lens-survey@5.2.5-latest.20211001.2
47 silly saveTree +-- lens-telemetry@5.2.5-latest.20211001.2
47 silly saveTree `-- lenscloud-lens-extension@5.2.5-latest.20211001.2
48 verbose type system
49 verbose stack FetchError: request to https://registry.npmjs.org/react-open-doodles failed, reason: connect ETIMEDOUT 104.16.27.35:443
49 verbose stack     at ClientRequest.<anonymous> (C:\Users\user\AppData\Local\Programs\kontena-lens\resources\app.asar\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
49 verbose stack     at ClientRequest.emit (events.js:315:20)
49 verbose stack     at TLSSocket.socketErrorListener (_http_client.js:469:9)
49 verbose stack     at TLSSocket.emit (events.js:315:20)
49 verbose stack     at emitErrorNT (internal/streams/destroy.js:106:8)
49 verbose stack     at emitErrorCloseNT (internal/streams/destroy.js:74:3)
49 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:80:21)
50 verbose cwd C:\Users\user\AppData\Roaming\Lens
51 verbose Windows_NT 10.0.14393
52 verbose argv "C:\\Users\\user\\AppData\\Local\\Programs\\kontena-lens\\Lens.exe" "C:\\Users\\user\\AppData\\Local\\Programs\\kontena-lens\\resources\\app.asar\\node_modules\\npm\\bin\\npm-cli.js" "install" "--no-audit" "--only=prod" "--prefer-offline" "--no-package-lock"
53 verbose node v14.16.0
54 verbose npm  v6.14.13
55 error code ETIMEDOUT
56 error errno ETIMEDOUT
57 error network request to https://registry.npmjs.org/react-open-doodles failed, reason: connect ETIMEDOUT 104.16.27.35:443
58 error network This is a problem related to network connectivity.
58 error network In most cases you are behind a proxy or have bad network settings.
58 error network
58 error network If you are behind a proxy, please make sure that the
58 error network 'proxy' config is set properly.  See: 'npm help config'
59 verbose exit [ 1, true ]
vbskruger commented 2 years ago

A temporary solution is to create a .npmrc file and place it in your home folder (i.e. c:\Users\theUser\.npmrc), with the following content:

https-proxy=http://your.proxy.address.with.port:8080

# If your proxy / firewall does packet inspections and alters the certificates, you can add your custom certificate authority here
ca[]="-----BEGIN CERTIFICATE-----\ntheCertificateInBase64With\n-----END CERTIFICATE-----"
ca[]="-----BEGIN CERTIFICATE-----\nYouCanUseMultipleCA\n-----END CERTIFICATE-----"

Form more info about the .npmrc, you can check here: https://docs.npmjs.com/cli/v7/using-npm/config#https-proxy https://docs.npmjs.com/cli/v7/using-npm/config#ca

Nokel81 commented 2 years ago

You can also just delete the C:/Users/user/AppData/Local/Programs/kontena-lens/resources/extensions/example-extension folder as it is not necessary. This is probably causing the initial issue as it should be the only bundled extension that actually has any run-time dependencies.