Skip to content

Commit

Permalink
set a timer to track each packet of data on update
Browse files Browse the repository at this point in the history
  • Loading branch information
alwasa0b authored and rwaldron committed Oct 23, 2017
1 parent 8b9aaa9 commit 959fa01
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/update-fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,15 @@ exportables.downloadTgz = function(tgzUrl, fileMap) {
return resolve(files);
});


remote.ifReachable(remote.BUILDS_HOSTNAME).then(() => {

var req = request.get(tgzUrl);

var startTimeout = () => setTimeout(() => {
reject(new Error('The attempt to download a build has timed out. Check your network connection and try again.'));
}, 10000);
var timeout = startTimeout();

// When we receive the response
req.on('response', (res) => {

Expand All @@ -185,6 +190,8 @@ exportables.downloadTgz = function(tgzUrl, fileMap) {
// When we get incoming data, update the progress bar
res.on('data', (chunk) => {
bar.tick(chunk.length);
clearTimeout(timeout);
timeout = startTimeout();
});

// unzip and extract the binary tarball
Expand Down

0 comments on commit 959fa01

Please # to comment.