Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
Fixed typo and added tests for http/s agents
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilogorek committed Sep 12, 2017
1 parent 6a7905e commit dbcd4e9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
17 changes: 7 additions & 10 deletions lib/transports.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var timeoutReq = require('timed-out');
var http = require('http');
var https = require('https');

var agentOptions = { keepalive: true, maxSockets: 100 };
var agentOptions = {keepAlive: true, maxSockets: 100};
var httpAgent = new http.Agent(agentOptions);
var httpsAgent = new https.Agent(agentOptions);

Expand Down Expand Up @@ -38,15 +38,12 @@ HTTPTransport.prototype.send = function(client, message, headers, eventId, cb) {
}

// prevent off heap memory explosion
var _agent = options.agent || this.transport.globalAgent;
if (_agent) {
var _name = client.dsn.host + ':' + client.dsn.port;
var _requests = _agent.requests[_name];
if (_requests && _requests.length > client.maxReqQueueCount) {
// other feedback strategy
client.emit('error', new Error('client req queue is full..'));
return;
}
var _name = client.dsn.host + ':' + client.dsn.port;
var _requests = options.agent.requests[_name];
if (_requests && _requests.length > client.maxReqQueueCount) {
// other feedback strategy
client.emit('error', new Error('client req queue is full..'));
return;
}

var req = this.transport.request(options, function(res) {
Expand Down
14 changes: 13 additions & 1 deletion test/raven.transports.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@

var transports = require('../lib/transports');

describe.only('transports', function() {
describe('transports', function() {
it('should have an http/s agent with correct config attached by default', function() {
var http = transports.http;
http.agent.should.exist;
http.agent.keepAlive.should.equal(true);
http.agent.maxSockets.should.equal(100);

var https = transports.https;
https.agent.should.exist;
https.agent.keepAlive.should.equal(true);
https.agent.maxSockets.should.equal(100);
});

it('should emit error when requests queued over the limit', function(done) {
var http = transports.http;
var _cachedAgent = http.options.agent;
Expand Down

0 comments on commit dbcd4e9

Please sign in to comment.