Repository navigation
Description
Describe the bug
When the server binds to the wildcard address 0.0.0.0, logServerAddress() calls getAddresses(), which calls os.networkInterfaces() unguarded. On platforms where enumerating the interface list is not permitted, os.networkInterfaces() throws, and because the call happens inside the server's listening event handler the exception escapes as an uncaught exception — the process dies instead of the server starting.
Concrete case: Android. A Node.js binary linked against glibc (e.g. a single-executable build) calls getifaddrs(), which needs CAP_NET_ADMIN for its NETLINK_ROUTE RTM_GETLINK dump and also reads /proc/net/if_inet6. Android denies both to ordinary apps, so getifaddrs() returns EACCES and Node throws:
SystemError [ERR_SYSTEM_ERROR]: A system error occurred: uv_interface_addresses returned Unknown system error 13 (Unknown system error 13)
at Object.networkInterfaces (node:os:218:16)
at getAddresses (/path/to/fastify/lib/server.js:...)
at Object.logServerAddress (/path/to/fastify/lib/server.js:...)
at Server.listeningEventHandler (/path/to/fastify/lib/server.js:...)
The same crash happens in any sandbox/container that forbids reading the interface list, not only Android. Note that binding to a specific address is unaffected — getAddresses() only calls os.networkInterfaces() for the 0.0.0.0 case.
Steps to reproduce
// repro.mjs
import os from 'node:os'
import Fastify from 'fastify'
// Stand in for a platform where interface enumeration is denied.
// (On Android this happens for real, see the stack trace above.)
const real = os.networkInterfaces
os.networkInterfaces = () => {
throw Object.assign(new Error('uv_interface_addresses returned Unknown system error 13'), {
code: 'ERR_SYSTEM_ERROR',
})
}
const app = Fastify()
app.get('/', async () => 'hello')
await app.listen({ host: '0.0.0.0', port: 0 })
console.log('listening')The await never settles: the exception is thrown in the listening event handler, so it is reported as an uncaught exception and the process exits with a non-zero code, instead of the server starting.
Expected behavior
Failing to enumerate the interface list should not be fatal. The server should still start, and the address list should fall back to the bound address (as it already does for a non-wildcard bind).
Suggested fix
Guard the call in getAddresses() and fall back to the bound address:
function getAddresses (address) {
if (address.address === '0.0.0.0') {
let interfaces
try {
interfaces = os.networkInterfaces()
} catch {
return [address.address]
}
return Object.values(interfaces).flatMap((iface) => {
return iface.filter((iface) => iface.family === 'IPv4')
}).sort((iface) => {
/* c8 ignore next 2 */
// Order the interfaces so that internal ones come first
return iface.internal ? -1 : 1
}).map((iface) => { return iface.address })
}
return [address.address]
}System Info
- fastify version: 5.8.5
- Node.js version: v24.15.0
- Platform: Android 12 (aarch64), Node linked against glibc
Activity
defaultuser233 commentedon Nov 26, 2026
复现验证(fastify 5.12.8,Node 24):
不带补丁时,
await app.listen()永不 resolve:异常抛在listening事件回调里,在 promise 链之外,
try/catch接不住,进程以未捕获异常退出。在测试里表现为整个测试文件挂住(199 秒后被超时杀掉),后续用例一个都没跑到。
带上
getAddresses()里的 catch 之后,同一个复现脚本正常打印listening。修复已提 PR:#7270 ——
getAddresses()里 catch 住os.networkInterfaces()的异常并回退到绑定地址;新增用例在无修复时会失败并把整个测试文件带崩。
另外补一条 Android 上的实测:官方 glibc 版 Node(nodejs.org v24.15.0 linux-arm64)在同一台
设备上跑
require('os').networkInterfaces()得到的是一模一样的uv_interface_addresses returned Unknown system error 13,所以这不是 Kimi Code 特有的问题。