Repository navigation
fix(server): do not crash when the interface list cannot be enumerated - #7270
Merged
mcollina merged 2 commits intoNov 28, 2026
Merged
Conversation
logServerAddress() calls getAddresses() when the server binds to the wildcard address, and getAddresses() calls os.networkInterfaces() without guarding it. That call throws on platforms where the interface list cannot be read - on Android the glibc implementation of getifaddrs() fails with EACCES because it needs CAP_NET_ADMIN for its NETLINK_ROUTE dump and /proc/net is not readable. The throw happens inside the server's 'listening' event handler, so it escapes as an uncaught exception and takes the whole process down: the listen() promise never settles and the server is gone. Fall back to the address that was bound to, so the server still starts. Fixes fastify#7268
mcollina
enabled auto-merge (squash)
November 26, 2026 21:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
logServerAddress()callsgetAddresses()when the server binds to the wildcard address, andgetAddresses()callsos.networkInterfaces()without guarding it.That call throws on platforms where the interface list cannot be read. On Android, for example, the glibc implementation of
getifaddrs()fails withEACCES: it needsCAP_NET_ADMINfor itsNETLINK_ROUTE(RTM_GETLINK) dump, and it also reads/proc/net/if_inet6, which Android does not expose to ordinary apps. bionic'sgetifaddrs()avoids both and works fine, which is why the failure is specific to glibc-linked builds.The throw happens inside the server's
listeningevent handler, so it escapes as an uncaught exception: thelisten()promise never settles and the process dies.Reproduction
Fix
Guard the call and fall back to the address the server bound to:
The server then starts as usual and still logs the address it is bound to.
Test
test/listen.1.test.jsgains a case that makesos.networkInterfaces()throw and asserts thatlisten()still completes:Without the fix the case fails with
code: 'ERR_SYSTEM_ERROR'and takes the rest of the test file down with it.Fixes #7268