Skip to content

Commit

Permalink
Merge pull request #984 from stephenplusplus/spp--core-request-timeout
Browse files Browse the repository at this point in the history
core: set a 60s timeout on HTTP requests
  • Loading branch information
callmehiphop committed Dec 3, 2015
2 parents ded1b11 + 4bbd1a9 commit 1ac48c3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var extend = require('extend');
var googleAuth = require('google-auto-auth');
var is = require('is');
var request = require('request').defaults({
timeout: 60000,
pool: {
maxSockets: Infinity
}
Expand Down
3 changes: 3 additions & 0 deletions lib/pubsub/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,9 @@ Subscription.prototype.pull = function(options, callback) {
}

this.request({
// The default timeout set used in this library is 60s, but a pull request
// times out around 90 seconds.
timeout: 90000,
method: 'POST',
uri: ':pull',
json: {
Expand Down
7 changes: 6 additions & 1 deletion test/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ describe('common/util', function() {
});

it('should have set correct defaults on Request', function() {
assert.deepEqual(REQUEST_DEFAULT_CONF, { pool: { maxSockets: Infinity } });
assert.deepEqual(REQUEST_DEFAULT_CONF, {
timeout: 60000,
pool: {
maxSockets: Infinity
}
});
});

it('should export an error for module instantiation errors', function() {
Expand Down
1 change: 1 addition & 0 deletions test/pubsub/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ describe('Subscription', function() {
it('should make correct api request', function(done) {
subscription.request = function(reqOpts) {
assert.strictEqual(reqOpts.method, 'POST');
assert.strictEqual(reqOpts.timeout, 90000);
assert.strictEqual(reqOpts.uri, ':pull');
assert.strictEqual(reqOpts.json.returnImmediately, false);
assert.strictEqual(reqOpts.json.maxMessages, 1);
Expand Down

0 comments on commit 1ac48c3

Please sign in to comment.