diff --git a/lib/adapters/http.js b/lib/adapters/http.js index aa0cfa2..9c7776c 100755 --- a/lib/adapters/http.js +++ b/lib/adapters/http.js @@ -346,7 +346,8 @@ module.exports = function httpAdapter(config) { // Handle errors req.on('error', function handleRequestError(err) { - if (req.aborted && err.code !== AxiosError.ERR_FR_TOO_MANY_REDIRECTS) return; + // @todo remove + // if (req.aborted && err.code !== AxiosError.ERR_FR_TOO_MANY_REDIRECTS) return; reject(AxiosError.from(err, null, config, req)); }); diff --git a/test/unit/adapters/http.js b/test/unit/adapters/http.js index 1183b05..6654b6c 100644 --- a/test/unit/adapters/http.js +++ b/test/unit/adapters/http.js @@ -141,7 +141,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, 'oops, timeout'); + assert.strictEqual(error.message, 'timeout of 250ms exceeded'); done(); }, 300); }); @@ -237,6 +237,8 @@ describe('supports http with nodejs', function () { axios.get('http://localhost:4444/', { maxRedirects: 3 }).catch(function (error) { + assert.equal(error.code, AxiosError.ERR_FR_TOO_MANY_REDIRECTS); + assert.equal(error.message, 'Maximum number of redirects exceeded'); done(); }); }); @@ -252,11 +254,13 @@ describe('supports http with nodejs', function () { maxRedirects: 3, beforeRedirect: function (options) { if (options.path === '/foo') { - throw new Error('path not allowed'); + throw new Error( + 'Provided path is not allowed' + ); } } }).catch(function (error) { - assert.equal(error.toJSON().message, 'path not allowed') + assert.equal(error.message, 'Provided path is not allowed'); done(); }); }); @@ -1087,7 +1091,7 @@ describe('supports http with nodejs', function () { setTimeout(function () { assert.equal(success, false, 'request should not succeed'); assert.equal(failure, true, 'request should fail'); - assert.equal(error.message, 'Malformed URL tel:484-695-3408'); + assert.equal(error.message, 'Unsupported protocol tel:'); done(); }, 300); }) @@ -1172,8 +1176,8 @@ describe('supports http with nodejs', function () { }).finally(function () { assert.strictEqual(success, false, 'request should not succeed'); assert.strictEqual(failure, true, 'request should fail'); - assert.strictEqual(error.code, 'ERR_REQUEST_ABORTED'); - assert.strictEqual(error.message, 'error request aborted'); + assert.strictEqual(error.code, 'ERR_BAD_RESPONSE'); + assert.strictEqual(error.message, 'maxContentLength size of -1 exceeded'); done(); }); });