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

Check if network adapter exists in Node.js before trying to connect #75

Closed
Richienb opened this issue Oct 5, 2020 · 1 comment · Fixed by #76
Closed

Check if network adapter exists in Node.js before trying to connect #75

Richienb opened this issue Oct 5, 2020 · 1 comment · Fixed by #76

Comments

@Richienb
Copy link
Contributor

Richienb commented Oct 5, 2020

This has a similar purpose to navigator.onLine where we can exit early if we can't find a network interface to connect to the internet with:

const os = require('os');

const networkInterfaceExists = Object.values(os.networkInterfaces()).flat().some(({internal}) => !internal);
@sindresorhus
Copy link
Owner

👍🏻

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

Successfully merging a pull request may close this issue.

2 participants