2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-08 17:22:34 +03:00

Fixed The timeoutErrorMessage property in config not work with Node.js (fixes #3580) (#3581)

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

* Adding "should respect the timeoutErrorMessage property" test case

Co-authored-by: Will Loo <duibu05@126.com>

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

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

* Updating http adapter

* Adding reject config.timeoutErrorMessage when setup

Co-authored-by: Will Loo <duibu05@126.com>

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

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

* Update http adapter

* Make changes as suggested after code review

Co-authored-by: Will Loo <duibu05@126.com>

Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
duibu05
2022-01-19 00:40:18 +08:00
committed by GitHub
parent 5c5cbdf4ba
commit 4461761fcb
2 changed files with 37 additions and 1 deletions
+7 -1
View File
@@ -349,9 +349,15 @@ 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 = '';
if (config.timeoutErrorMessage) {
timeoutErrorMessage = config.timeoutErrorMessage;
} else {
timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
}
var transitional = config.transitional || defaults.transitional;
reject(createError(
'timeout of ' + timeout + 'ms exceeded',
timeoutErrorMessage,
config,
transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
req