LinkedInAttic/sepia

Duplicate Requests being recorded

jimmyeisenhauer opened this issue · 5 comments

I have set up sepia with the below express and proxy server and I am getting two recordings 1 with http and 1 with https. The server is setup as http and proxies to https. Is this something I could fix on the sepia side? Or is this with how the proxy is handling the http requests?

Thanks!

var server = express();
server.set('port', 3000);

var apiProxy = httpProxy.createProxyServer();
var apiForwardingUrl = 'https://commerce-api.example.com';
console.log('Forwarding API requests to ' + apiForwardingUrl);

// commerce api
server.all("/commerce/*", function(req, res) {
apiProxy.web(req, res, {
target: apiForwardingUrl,
agent: https.globalAgent,
headers: {
host: 'commerce-api.example.com'
}
});
});

server.listen(server.get('port'), function() {
console.log(' server'.blue + ' started '.green.bold + 'on port '.blue + server.get('port'));

});

Hi @jameseisenhauer: Sorry for the delay, but unfortunately, without knowing the exact tools you're using (which proxy server?), I wouldn't be able to answer the question. Could you check if the proxy is actually making two outbound requests or just one?

I found out what was writing the request twice. It is this line in the cache file: ['http', 'https'].forEach(function(protocol) {

I am using nodejitsu http-proxy so on a http-->https proxy it seems to be sending both objects. Can you recommend a way to only run https if it and http objects exist without impacting the rest of the code? Today I plan to dig into it and test out a few ideas. thanks!

I'm not using a proxy at all and I am seeing this behavior

Yeah the sepia library in cache.js seems to be making 2 requests like @jimmyeisenhauer mentions

I was just looking at this in the replayer fork. What's happening is that the function is being wrapped twice. I rewrote some of this code to add enable/disable in the replayer fork. The changes should make this easy to fix. I'll track this issue over there.