Skip to content

Commit

Permalink
Added a optional heartbeat option so we can combat Chrome unstable ha…
Browse files Browse the repository at this point in the history
…nging and keep using it to ensure we are on the bleeding edge
  • Loading branch information
Johanndutoit committed Sep 14, 2017
1 parent 3f85828 commit 6181eca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = exports = function(options) {
ignoreSSL: true,

contentTypes: [].concat(options.contentTypes || []),

userAgent: options.userAgent || null,

cpu: null,
Expand Down
18 changes: 15 additions & 3 deletions lib/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ module.exports = exports = function(options) {
// setup handlers
Network.requestWillBeSent((params) => {

// flash a heartbeat
if(options.heartbeat) options.heartbeat();

if(VARS.started === null) {

// start tracking when the page started
Expand Down Expand Up @@ -264,9 +267,9 @@ module.exports = exports = function(options) {
// Disabled as we don't need it for now
Network.dataReceived(({requestId, dataLength}) => {

const entry = VARS.requests[requestId];
if (!entry) return;
entry.responseLength += dataLength;
const entry = VARS.requests[requestId];
if (!entry) return;
entry.responseLength += dataLength;

});

Expand Down Expand Up @@ -453,6 +456,9 @@ module.exports = exports = function(options) {

Network.responseReceived(function(params) {

// flash a heartbeat
if(options.heartbeat) options.heartbeat();

// the resource
var resource = VARS.requests[params.requestId];

Expand Down Expand Up @@ -882,6 +888,9 @@ module.exports = exports = function(options) {
Promise.all(promises)
.then(() => {

// flash a heartbeat
if(options.heartbeat) options.heartbeat();

// options to navigate to
var navigateOptions = {

Expand Down Expand Up @@ -952,6 +961,9 @@ module.exports = exports = function(options) {

}).catch((err) => {

// flash a heartbeat
if(options.heartbeat) options.heartbeat();

// output the error
console.dir(err)

Expand Down

0 comments on commit 6181eca

Please sign in to comment.