mirror of
https://github.com/tenrok/axios.git
synced 2026-05-15 11:59:42 +03:00
Fix/4737/timeout error message for http (#4738)
* Fixing timeoutErrorMessage in http calls When timeoutErrorMessage was set this did not change anything in the error message, with this change the error message will be the configured message * Testing timeoutErrorMessage in http calls When timeoutErrorMessage was set this did not change anything in the error message, with this change the error message will be the configured message Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
@@ -420,9 +420,13 @@ 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 = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
|
||||
var transitional = config.transitional || transitionalDefaults;
|
||||
if (config.timeoutErrorMessage) {
|
||||
timeoutErrorMessage = config.timeoutErrorMessage;
|
||||
}
|
||||
reject(new AxiosError(
|
||||
'timeout of ' + timeout + 'ms exceeded',
|
||||
timeoutErrorMessage,
|
||||
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
||||
config,
|
||||
req
|
||||
|
||||
@@ -146,7 +146,7 @@ describe('supports http with nodejs', function () {
|
||||
assert.strictEqual(success, false, 'request should not succeed');
|
||||
assert.strictEqual(failure, true, 'request should fail');
|
||||
assert.strictEqual(error.code, 'ECONNABORTED');
|
||||
assert.strictEqual(error.message, 'timeout of 250ms exceeded');
|
||||
assert.strictEqual(error.message, 'oops, timeout');
|
||||
done();
|
||||
}, 300);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user