looks like when nodejs is linked against libhttp-parser the "behind proxy functionality" is broken (which works however when build against the internal parser) - take a look at the last two comments on https://github.com/npm/npm/issues/3084 this is probably a nodejs issue, however this bug is about changing the gentoo nodejs ebuild to link against the nodejs internal http-parser instead against libhttp-parse, or make a USE flag for this. I could reproduce this easily when I try npm install elm having this ~/.npmrc proxy=http://myproxy:8080/ https-proxy=http://myproxy:8080/ N.B. Note that only https destinations are affected, i.e. npm will download most http urls, but fail on the first https request with ParseError: npm http request GET https://registry.npmjs.org/elm npm info retry will retry, error on last attempt: Error: tunneling socket could not be established, cause=Parse Error
Instead of providing your solution to an obvious bug, why don't you tell us which version of net-libs/nodejs and net-libs/http-parser you used?
with yarn I have the same problem gentoo-x64-proxy ~/test # http_proxy=http://localhost:3128 https_proxy=http://localhost:3128 yarn add @rails/webpacker result in: yarn add v1.2.1 info No lockfile found. [1/4] Resolving packages... info There appears to be trouble with your network connection. Retrying... info There appears to be trouble with your network connection. Retrying... info There appears to be trouble with your network connection. Retrying... info There appears to be trouble with your network connection. Retrying... error An unexpected error occurred: "https://registry.yarnpkg.com/@rails%2fwebpacker: tunneling socket could not be established, cause=Parse Error". info If you think this is a bug, please open a bug report with the information provided in "/root/test/yarn-error.log". info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command. the yarn config gentoo-x64-proxy ~/test # yarn config list yarn config v1.2.1 info yarn config { 'version-tag-prefix': 'v', 'version-git-tag': true, 'version-git-sign': false, 'version-git-message': 'v%s', 'init-version': '1.0.0', 'init-license': 'MIT', 'save-prefix': '^', 'ignore-scripts': false, 'ignore-optional': false, registry: 'https://registry.yarnpkg.com', 'strict-ssl': true, 'user-agent': 'yarn/1.2.1 npm/? node/v6.11.5 linux x64', lastUpdateCheck: 1513285512197 } info npm config {} Done in 0.04s. I have tried with the proxy defined in yarn config with the same result. The registry is not available as http, so I don't know any workaround. With npm the results are the same I checked with whireshark and i can confirm that the CONNECT request is issued and receive a 200 http response but yarn/node don't understand and are retrying some times before aborting. The system: [ebuild R ~] sys-apps/yarn-1.2.1::gentoo 0 KiB [ebuild R ] net-libs/nodejs-6.11.5::gentoo USE="npm snapshot ssl -debug -doc -icu {-test}" CPU_FLAGS_X86="sse2" PYTHON_TARGETS="python2_7" 0 KiB Linux gentoo-x64-proxy 4.12.12-gentoo #1 SMP Wed Sep 13 21:07:07 CEST 2017 x86_64 Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz GenuineIntel GNU/Linux gentoo-x64-proxy ~/test # emerge --info Portage 2.3.13 (python 3.5.4-final-0, default/linux/amd64/17.0, gcc-6.4.0, glibc-2.25-r9, 4.12.12-gentoo x86_64) ================================================================= System uname: Linux-4.12.12-gentoo-x86_64-Intel-R-_Core-TM-_i7-3770_CPU_@_3.40GHz-with-gentoo-2.4.1 KiB Mem: 1014672 total, 208588 free Timestamp of repository gentoo: Fri, 15 Dec 2017 19:00:01 +0000 Head commit of repository gentoo: cc41b72787e64f638988f76cc5a91be65223ac55 sh bash 4.3_p48-r1 ld GNU ld (Gentoo 2.29.1 p3) 2.29.1 app-shells/bash: 4.3_p48-r1::gentoo dev-lang/perl: 5.24.3::gentoo dev-lang/python: 2.7.14-r1::gentoo, 3.4.5::gentoo, 3.5.4-r1::gentoo dev-util/pkgconfig: 0.29.2::gentoo sys-apps/baselayout: 2.4.1-r2::gentoo sys-apps/openrc: 0.34.11::gentoo sys-apps/sandbox: 2.10-r4::gentoo sys-devel/autoconf: 2.69::gentoo sys-devel/automake: 1.15.1-r1::gentoo sys-devel/binutils: 2.29.1-r1::gentoo sys-devel/gcc: 6.4.0::gentoo sys-devel/gcc-config: 1.8-r1::gentoo sys-devel/libtool: 2.4.6-r3::gentoo sys-devel/make: 4.2.1::gentoo sys-kernel/linux-headers: 4.4::gentoo (virtual/os-headers) sys-libs/glibc: 2.25-r9::gentoo Repositories: gentoo location: /usr/portage sync-type: rsync sync-uri: rsync://rsync.gentoo.org/gentoo-portage priority: -1000 sync-rsync-extra-opts: ACCEPT_KEYWORDS="amd64" ACCEPT_LICENSE="* -@EULA" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-march=corei7 -O2 -pipe" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo" CXXFLAGS="-march=corei7 -O2 -pipe" DISTDIR="/var/portage/distfiles" FCFLAGS="-O2 -pipe" FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync multilib-strict news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr" FFLAGS="-O2 -pipe" GENTOO_MIRRORS="http://gentoo.modulix.net/gentoo/ http://gentoo.mirrors.ovh.net/gentoo-distfiles/ http://mirrors.linuxant.fr/distfiles.gentoo.org/" LANG="fr_FR.UTF-8" LC_ALL="fr_FR.UTF-8" LDFLAGS="-Wl,-O1 -Wl,--as-needed" MAKEOPTS="-j3" PKGDIR="/var/portage/packages" PORTAGE_CONFIGROOT="/" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git" PORTAGE_TMPDIR="/var/tmp" USE="acl amd64 berkdb bindist bzip2 cli cracklib crypt cxx dri fortran gdbm iconv ldap logrotate mmx modules multilib ncurses nls nptl oci8-instant-client openmp pam pcre readline seccomp session sse sse2 ssl symlink tcpd unicode vhosts xattr zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6 php7-0" POSTGRES_TARGETS="postgres9_5" PYTHON_SINGLE_TARGET="python3_5" PYTHON_TARGETS="python2_7 python3_5" RUBY_TARGETS="ruby24" USERLAND="GNU" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" Unset: CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Closing due to inactivity. Please reopen with updated information if this is still a problem.