http-party / node-portfinder

A simple tool to find an open port or domain socket on the current machine
https://github.com/http-party/node-portfinder
Other
882 stars 95 forks source link

If callback is passed to getPort() then all errors should be returned as first parameter of callback #111

Closed amardeokar23 closed 3 years ago

amardeokar23 commented 4 years ago

Errors generated due to providing startPort < 0 OR basePort > highestPort need to be returned in the callback if callback is provided. Otherwise errors will not be caught unless user call getPort() inside try-catch.

https://github.com/http-party/node-portfinder/blob/8895293a96a41a454b6648b50ecc7bff7f13fc22/lib/portfinder.js#L118

eriktrom commented 3 years ago

i never answered this sorry

so u are right -- problem is long ago i did a bunch of error catching and bubbling to the user stuff, then when windows WSL was released there was a flood of syscall errors (macos touchbar did the same) and at that point i removed errors to help the user b/c the syscall errors were so os dependent that I couldn't say for sure I wasn't making things harder to debug than easier...

tldr...