diff --git a/lib/should-retry.js b/lib/should-retry.js index c30a5ad0e..ce0af386c 100644 --- a/lib/should-retry.js +++ b/lib/should-retry.js @@ -18,5 +18,6 @@ module.exports = function shouldRetry(err, res) { if (res && res.status && res.status >= 500) return true; // Superagent timeout if (err && 'timeout' in err && err.code == 'ECONNABORTED') return true; + if (err && 'crossDomain' in err) return true; return false; -}; \ No newline at end of file +}; diff --git a/test/client/xdomain.js b/test/client/xdomain.js index 9b80ad5b9..5b2f83e10 100644 --- a/test/client/xdomain.js +++ b/test/client/xdomain.js @@ -30,5 +30,21 @@ describe('xdomain', function(){ next(); }); }); + + it('should handle x-domain failure after repeat attempts', function(next){ + request + .get('//tunne127.com') + .retry(2) + .end(function(err, res){ + try { + assert(err, 'error missing'); + assert(err.crossDomain, 'not .crossDomain'); + assert.equal(2, err.retries, 'expected an error with .retries'); + next(); + } catch(err) { + next(err); + } + }); + }); } });