Skip to content

Commit

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

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

* Updating http adapter

* Adding reject config.timeoutErrorMessage when setup

Co-authored-by: Will Loo <duibu05@126.com>
  • Loading branch information
duibu05 committed Jan 22, 2021
1 parent a2f56b0 commit 5df1126
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/adapters/http.js
Expand Up @@ -277,7 +277,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(config.timeout, function handleRequestTimeout() {
req.abort();
reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', req));
var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
if (config.timeoutErrorMessage) {
timeoutErrorMessage = config.timeoutErrorMessage;
}
reject(createError(timeoutErrorMessage, config, 'ECONNABORTED', req));
});
}

Expand Down

0 comments on commit 5df1126

Please sign in to comment.