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

Misleading values in returned object when the cable is unplugged or the host doesn't exist #133

Closed
lucamarogna opened this issue Dec 18, 2020 · 6 comments

Comments

@lucamarogna
Copy link

lucamarogna commented Dec 18, 2020

Writing these tests:

console.log( await ping.promise.probe('fakehostdoesntexist.com') );
// Manually unplug the cable...
console.log( await ping.promise.probe('google.com') );

both result in:

{
  host: 'unknown',
  alive: false,
  output: '',
  time: 'unknown',
  times: [],
  min: 'unknown',
  max: 'unknown',
  avg: 'unknown',
  stddev: 'unknown',
  packetLoss: 'unknown'
}

(the latter happen only when the network cable is unplugged)

I think it should have at least the host property setted to the actual host pinged. Not sure for other properties as ping implementation may vary depending on platforms (I'm on Ubuntu 18.04.3).

@mondwan
Copy link
Collaborator

mondwan commented Dec 19, 2020 via email

@lucamarogna
Copy link
Author

Ok that's totally fine.

For me, it would be better to have the host value because I'm running several promises in parallel (Promise.all()) and I didn't know which has failed (e.g. "fakehostdoesntexist.com"), but I do catch your point.

Thank you for your response and explanation.

@mondwan
Copy link
Collaborator

mondwan commented Dec 23, 2020

For your case, how about adding a key, say, userInputHost in the response object.

Therefore, we have around 3 keys talking about hosts but with subtle difference:

  • userInputHost: As title, host inputted from user
  • host: Host parsed from the system command
  • numeric_host: Host parsed, if possible, from the system command in a numeric format

Hopefully, it can address your issue

mondwan pushed a commit that referenced this issue Dec 26, 2020
@mondwan
Copy link
Collaborator

mondwan commented Dec 26, 2020

You can checkout this new implementation in the master branch on github.

@HughDai
Copy link

HughDai commented Apr 7, 2021

For your case, how about adding a key, say, userInputHost in the response object.

Therefore, we have around 3 keys talking about hosts but with subtle difference:

  • userInputHost: As title, host inputted from user
  • host: Host parsed from the system command
  • numeric_host: Host parsed, if possible, from the system command in a numeric format

Hopefully, it can address your issue

I don't find this commit in the latest npm version v0.4.0 . Could you please check it, thanks a lot.

@mondwan
Copy link
Collaborator

mondwan commented Apr 7, 2021 via email

@mondwan mondwan closed this as completed Apr 8, 2021
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