Skip to content

Commit

Permalink
Reverse decision to fail early on EHOSTUNREACH errors
Browse files Browse the repository at this point in the history
Mistake to exit early for these errors as it is possible subsequent retries may succeed
i.e. temporary network failure.
  • Loading branch information
theophilusx committed Jul 13, 2022
1 parent a46bae3 commit 553b7e1
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,17 @@ class SftpClient {
switch (err.code) {
case 'ENOTFOUND':
case 'ECONNREFUSED':
case 'EHOSTUNREACH':
case 'ERR_SOCKET_BAD_PORT':
throw err;
case undefined: {
if (err.message.endsWith('All configured authentication methods failed')) {
throw this.fmtError(err.message, 'getConnection', errorCode.badAuth);
}
retry(err);
break;
throw err;
case undefined: {
if (err.message.endsWith('All configured authentication methods failed')) {
throw this.fmtError(err.message, 'getConnection', errorCode.badAuth);
}
default:
retry(err);
retry(err);
break;
}
default:
retry(err);
}
}
});
Expand Down

0 comments on commit 553b7e1

Please # to comment.