Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os.networkInterfaces().family is no longer a string #42953

Closed
deftomat opened this issue May 3, 2022 · 3 comments
Closed

os.networkInterfaces().family is no longer a string #42953

deftomat opened this issue May 3, 2022 · 3 comments

Comments

@deftomat
Copy link

deftomat commented May 3, 2022

Version

v18.0.0

Platform

Darwin 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:46:32 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T6000 arm64

Subsystem

os

What steps will reproduce the bug?

The following code will throw an error as family is either a number 4 or 6.
Previously, it was a string as described in documentation https://nodejs.org/api/os.html#osnetworkinterfaces

import { networkInterfaces } from 'os';

Object.values(networkInterfaces()).flat()[0].family.toLowerCase();

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

family should be either IPv4 or IPv6

What do you see instead?

Numbers 4 or 6

Additional information

No response

@panva
Copy link
Member

panva commented May 3, 2022

This was introduced in #41431, the change to networkInterfaces was not documented, despite test being updated to reflect the values 4 and 6 being returned now.

Two ways moving forward - fix the documentation (add v18.0.0 change entry and update the type), or revert the change to networkInterfaces.

cc @aduh95

@aduh95
Copy link
Contributor

aduh95 commented May 3, 2022

Duplicate of #42787. The doc fix has landed and should be released as part of Node.js 18.1.0 today.

@aduh95 aduh95 closed this as completed May 3, 2022
@deftomat
Copy link
Author

deftomat commented May 3, 2022

Thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants