Set timeout for HTTP requests.

This commit is contained in:
Mitar
2016-05-31 23:35:46 +02:00
parent 38a119f14d
commit 853e218a89

View File

@@ -12,6 +12,7 @@ var auth = require('../meteor-services/auth.js');
var config = require('../meteor-services/config.js');
var release = require('../packaging/release.js');
var Console = require('../console/console.js').Console;
var timeoutScaleFactor = require('./utils.js').timeoutScaleFactor;
// Helper that tracks bytes written to a writable
@@ -244,6 +245,12 @@ _.extend(exports, {
options.proxy = proxy;
}
if (! options.timeout) {
// 15 seconds for timeout between initial response headers and data,
// and between chunks of data while reading the rest of the response.
options.timeout = 15000 * timeoutScaleFactor;
}
// request is the most heavy-weight of the tool's npm dependencies; don't
// require it until we definitely need it.
Console.debug("Doing HTTP request: ", options.method || 'GET', options.url);