browsermob-node
browsermob-node copied to clipboard
Callback for Example Script never executes
Script:
var Proxy = require('browsermob-proxy').Proxy
, proxy = new Proxy()
, fs = require('fs');
console.log(' app running');
proxy.doHAR('http://yahoo.com', function(err, data) {
console.log('callback running');
if (err) {
console.error('ERROR: ' + err);
} else {
console.log('happy', data);
fs.writeFileSync('yahoo.com.har', data, 'utf8');
}
});
Output:
$ node index.js
app running
$
browsermob-proxy v2.1.4 is running and logs output when the script runs
[INFO 2017-02-22T11:27:48,264 org.littleshoot.proxy.impl.DefaultHttpProxyServer] (qtp26890590-15) Starting proxy at address: 0.0.0.0/0.0.0.0:8086
[INFO 2017-02-22T11:27:48,265 org.littleshoot.proxy.impl.DefaultHttpProxyServer] (qtp26890590-15) Proxy listening with TCP transport
[INFO 2017-02-22T11:27:48,266 org.littleshoot.proxy.impl.DefaultHttpProxyServer] (qtp26890590-15) Proxy started at address: /0:0:0:0:0:0:0:0:8086
this setup assumes the selenium server is running locally on port 4444 - is it?
I had to update browsermob-proxy/index.js#selFunc to add a .call(cb) because end() does not accept a callback anymore, which blocks doHAR from returning the data. @zzo @tlhunter