Skip to content

Commit

Permalink
Fixing The timeoutErrorMessage property in config not work with Node.…
Browse files Browse the repository at this point in the history
…js (axios#3580)

* Fixing The timeoutErrorMessage property in config not work with Node.js (axios#3580)

* Update http adapter

* Make changes as suggested after code review

Co-authored-by: Will Loo <duibu05@126.com>
  • Loading branch information
duibu05 committed Aug 17, 2021
1 parent cdd2b03 commit a381d5c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/adapters/http.js
Expand Up @@ -300,9 +300,11 @@ module.exports = function httpAdapter(config) {
// ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
req.setTimeout(timeout, function handleRequestTimeout() {
req.abort();
var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
var timeoutErrorMessage = '';
if (config.timeoutErrorMessage) {
timeoutErrorMessage = config.timeoutErrorMessage;
} else {
timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
}
reject(createError(timeoutErrorMessage, config, 'ECONNABORTED', req));
});
Expand Down

0 comments on commit a381d5c

Please sign in to comment.