Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: set a 60s timeout on HTTP requests #984

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
core: set a 60s timeout on HTTP requests
  • Loading branch information
stephenplusplus committed Dec 2, 2015
commit 4bbd1a98fdcab280036a568115d0c2a9a7a9ef36
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