Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Commit af9804e

Browse files
authored
fix: intermittent error when asking for interfaces (#137)
Get interfaces only once per run
1 parent e9e1f56 commit af9804e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/utils.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ function isAnyAddr (ip) {
2929
* @param {string} family One of ['IPv6', 'IPv4']
3030
* @returns {string[]} an array of ip address strings
3131
*/
32+
const networks = os.networkInterfaces()
3233
function getNetworkAddrs (family) {
33-
return Object.values(os.networkInterfaces()).reduce((addresses, netAddrs) => {
34+
return Object.values(networks).reduce((addresses, netAddrs) => {
3435
netAddrs.forEach(netAddr => {
3536
// Add the ip of each matching network interface
3637
if (netAddr.family === family) addresses.push(netAddr.address)

0 commit comments

Comments
 (0)