Skip to content

Commit a8fae7e

Browse files
authored
Add requests timeout and retry on timeout (#126)
1 parent ed471e5 commit a8fae7e

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/chartmogul/util/retry.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const RETRIABLE_ERRORS = [
2222
'ECONNREFUSED',
2323
'EHOSTUNREACH',
2424
'EPIPE',
25-
'EAI_AGAIN'
25+
'EAI_AGAIN',
26+
'ECONNABORTED'
2627
];
2728

2829
function retryOnNetworkError (err) {
@@ -49,6 +50,7 @@ module.exports = function retryRequest (retries, options, cb) {
4950
const request = superagent(options.method || 'get', requestUrl)
5051
.auth(options.auth.user, options.auth.pass)
5152
.set(options.headers)
53+
.timeout({ response: 30000, deadline: 120000 })
5254
.query(options.qs)
5355
.send(options.body);
5456

0 commit comments

Comments
 (0)