nix-community / napalm

Support for building npm packages in Nix and lightweight npm registry [maintainer=?]
MIT License
104 stars 17 forks source link

napalm-registry maybe should listen on ::1 as well as on 127.0.0.1? #56

Open mstone opened 1 year ago

mstone commented 1 year ago

I just ran into an interesting issue (and arguably, an impurity in flakes on darwin) while trying to build https://github.com/ejgallego/coq-lsp?submodules=1#packages.aarch64_darwin.vscode-extension.

The symptom of the problem is that nix build -L hangs with npm error messages like:

...
coq-lsp> npm verb audit error FetchError: request to http://localhost:60584/-/npm/v1/security/audits/quick failed, reason: connect ECONNREFUSED ::1:60584

and then npm and napalm need to be force-killed in order to get the nix builder to exit (even after hitting Ctrl-C to interrupt the build).

Digging into the logs further, I noticed that although napalm is nominally binding to "localhost" while npm is connecting to "::1", which ought to work, it turns out that napalm is actually only listening on 127.0.0.1:

$ sudo lsof -i -n -P | grep LISTEN | grep napalm
napalm-re 44648       _nixbld1    3u  IPv4 0x2da8d7fea15bbb1f      0t0    TCP 127.0.0.1:60584 (LISTEN)

Anyway, after noodling on this for a bit, I took a look at /etc/hosts:

$ cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost

and, sure enough, commenting out the ::1 entry enables the build to succeed.

jtojnar commented 1 year ago

Thanks for reporting, I opened https://github.com/nix-community/napalm/pull/57.