nodejs / help

:sparkles: Need help with Node.js? File an Issue here. :rocket:
1.47k stars 280 forks source link

npm install fails on old laptops #4327

Open owlbrudder opened 8 months ago

owlbrudder commented 8 months ago

Details

I have three machines, all running Fedora 38. The desktop is the main development machine, but I have two rather ancient laptops I use as test beds.

Currently I am working with the team on GitHub project opensourcepos. The desktop machine behaves perfectly, but both the old laptops running dual core Celeron CPUs and 4Gb RAM always get ECONNRESET errors when I run npm install.

All three machines are connected to the same modem and there is no proxy involved.

Is there a hardware lower limit to the capabilities of npm?

Node.js version

node.js v18.19.0 npm v10.2.3

Example code

No response

Operating system

Linux david 6.6.9-100.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jan 1 20:31:07 UTC 2024 x86_64 GNU/Linux

Scope

When running npm install for the opensourcepos project

Module and version

Not applicable.

preveen-stack commented 8 months ago

Can you share the error log you are getting

owlbrudder commented 8 months ago

Thank you for replying. Setting the log to verbose, I see many lines beginning with 'timing', then a TLSWrap.onStreamRead error, then it finishes with many 'unfinished npm timer' lines. The point of failure changes each time I run the command, but the error is the same. The relevant part of a typical log is this (I have added the bold):

939 timing reifyNode:node_modules/estraverse Completed in 14168ms 940 timing reifyNode:node_modules/is-bigint Completed in 14227ms 941 timing reifyNode:node_modules/mkdirp Completed in 14319ms 942 timing reifyNode:node_modules/file-uri-to-path Completed in 14235ms 943 timing reifyNode:node_modules/lru-cache Completed in 14308ms 944 verbose stack Error: read ECONNRESET 944 verbose stack at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20) 945 verbose cwd /home/doug/public_html/ci4-branch/opensourcepos 946 verbose Linux 6.6.11-100.fc38.x86_64 947 verbose node v18.19.0 948 verbose npm v10.2.3 949 error code ECONNRESET 950 error syscall read 951 error errno -104 952 error network read ECONNRESET 953 error network This is a problem related to network connectivity. 953 error network In most cases you are behind a proxy or have bad network settings. 953 error network 953 error network If you are behind a proxy, please make sure that the 953 error network 'proxy' config is set properly. See: 'npm help config' 954 verbose exit -104 955 timing npm Completed in 24198ms 956 verbose unfinished npm timer command:ci 1705466510019 957 verbose unfinished npm timer reify 1705466518548 958 verbose unfinished npm timer reify:audit 1705466518867 959 verbose unfinished npm timer auditReport:getReport 1705466518868 960 verbose unfinished npm timer reify:unpack 1705466518925

owlbrudder commented 8 months ago

Following a suggestion turned up by Google, I tried

openssl s_client -msg -debug -state -connect registry.npmjs.org:443

This worked perfectly well with zero reported problems.

preveen-stack commented 8 months ago

Thanks for sharing the fix. Can you post the link to the fix

owlbrudder commented 8 months ago

My apologies for confusing you. It has not fixed my problem. I was just saying this test of the low level comms worked correctly. The laptop still gets ECONNRESET when running npm ci.

For completeness, the link I saw was: https://stackoverflow.com/questions/21767003/ssl-handshake-fails-after-clienthello

preveen-stack commented 8 months ago

Please provide full error log as a gist.

Also can perhaps connect to another network temporarily and check

owlbrudder commented 8 months ago

I have pasted the full verbose log into gist https://gist.github.com/owlbrudder/242250158aff52c34ac524326d1f900c

I have tried using my cellphone as a hotspot to get away from the modem normally used, but the result is the same.

The failure occurs at different places on each run. The desktop computer using the identical setup runs without error.

preveen-stack commented 8 months ago

Thanks for sharing the detailed log.

Could you perhaps try https://docs.npmjs.com/cli/v10/using-npm/config#maxsockets

Also, see if this work around is of any help https://github.com/npm/npm/issues/18903#issuecomment-382368672

owlbrudder commented 8 months ago

I will try adjusting that - it sounds promising. I tried a number of different maxsockets settings with no improvement .. until I set it to 1 and the old machine slowly ground its way a lot further through the job, but still died. I will rerun several times to see if it can progressively get through.

EDIT: SUCCESS!! Setting maxsockets to 1 on both the old laptops has seen them run npm ci to completion. Thank you very much for the pointer in that direction.

I did try http at one point, but the problem persisted.

preveen-stack commented 8 months ago

Can you check syslog to see if eveything is okay

owlbrudder commented 8 months ago

I could not find anything called syslog, but this is what was sent to the terminal: `[doug@david opensourcepos]$ npm ci npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated npm WARN deprecated har-validator@5.1.5: this library is no longer supported npm WARN deprecated abab@1.0.4: Use your platform's native atob() and btoa() methods instead npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated npm WARN deprecated xmldom@0.1.31: Deprecated due to CVE-2021-21366 resolved in 0.5.0 npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142

added 1040 packages, and audited 1041 packages in 24m

135 packages are looking for funding run npm fund for details

17 vulnerabilities (4 moderate, 12 high, 1 critical)

To address issues that do not require attention, run: npm audit fix

To address all issues possible (including breaking changes), run: npm audit fix --force

Some issues need review, and may require choosing a different dependency.

Run npm audit for details. `

preveen-stack commented 8 months ago

https://www.linuxfoundation.org/blog/blog/classic-sysadmin-viewing-linux-logs-from-the-command-line HTH

owlbrudder commented 8 months ago

One mystery solved: Fedora does not install rsyslog by default, which is why I have never seen a file called syslog. I have just installed it and am now trying to work out what configuration I need in order to see the socket misbehaviour.

RedYetiDev commented 3 months ago

Is this issue still occuring? If not, feel free to self-close.