alallier/reload

Reject with error on http server error

xyc opened this issue · 1 comments

xyc commented

Use case: When the port is already in use (for example in 9856), the library throws an uncaughtException. This prevents the upstream consumer from further handling the error.

Proposed fix is to add following error handler after

reload/lib/reload.js

Lines 168 to 170 in c0271a6

httpOrHttpsServer.listen(port, function () {
resolve(getReloadReturn())
})

httpOrHttpsServer.on('error', function(error) {
    reject(error);
});

Reference:
https://stackoverflow.com/a/14470248

Thanks for the report, PRs welcomed