-
Notifications
You must be signed in to change notification settings - Fork 22
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
[Feature Request]: Throw Error if net-tools is not installed #41
Comments
@nktnet1 do you currently receive an error from node-netstat when netstat is missing? I would guess something like an ENOENT error? Telling the user they must install some package is outside the scope of this project but I can certainly make sure it errors cleanly if netstat is missing or fails to run. |
@danielkrainas I don't think there's any error if net-tools is not installed - it just fails silently, like in my attached image, second command in the terminal. |
@nktnet1 understood - I will look to make sure it errors cleanly if netstat isn't installed or in PATH. |
@nktnet1 I see the issue - you need to add a
aside - I do see there's a bug where the done handler is called twice, first time with the error and second time without but I'll fix this. |
(1) I'm using the synchronous version (somehow missed this in the original image of the issue, my bad) - is there a way to avoid the done handler and simply have the Error thrown? Currently my usage is something like this (slightly simplified below): const getNetstat = (port: number, host: string): SyncResult => {
let results: SyncResult;
netstat({
sync: true,
filter: { local: { port, host } },
limit: 1,
}, (ret) => {
results = ret;
});
return results;
}; (2) Actually, on this note, it'll be awesome if the synchronous version can be written without the callback - can look into creating a PR if you think it's a good idea. For example, const getNetstat = (port: number, host: string): SyncResult => {
// synchronously return the result (instead of undefined) or throw an Error as appropriate
return netstat({
sync: true,
filter: { local: { port, host } },
limit: 1,
});
}; or maybe export a (3) Sorry off-topic again, but Happy to make new issues/PRs for (2) and (3) to not conflate issues if you'd like. Thanks @danielkrainas! |
I don't use this project in anything personally and only maintain it as a courtesy to the community that finds it useful. That said, the time to finally sit down and write V2 I think is long past due - with the renewed activity on this project, I will see what I can do to make it happen. Thank you for your interest in the project! |
Hello,
node-netstat currently does nothing if the command netstat is not found (i.e. net-tools is not installed). For example:
code source (click to view)
Commands and outputs:
This can be difficult to debug. On netstat's manual page, we have
so it's not uncommon for docker images and linux distributions do not ship with net-tools.
Would it be possible to simply throw an Error with a helpful message telling the user to install net-tools?
Thank you :)).
The text was updated successfully, but these errors were encountered: