Skip to content

Commit 9ce0e7b

Browse files
Add null check while updating progress bar
1 parent a70acc7 commit 9ce0e7b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

bin/helpers/zipUpload.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,15 @@ const uploadSuits = (bsConfig, filePath, opts, obj) => {
9696
});
9797

9898
obj.zipInterval = setInterval(function () {
99-
let dispatched = r.req.connection._bytesDispatched;
100-
let percent = dispatched * 100.0 / size;
101-
obj.bar1.update(percent, {
102-
speed: ((dispatched / (Date.now() - obj.startTime)) / 125).toFixed(2) //kbits per sec
103-
});
99+
if (r && r.req && r.req.connection) {
100+
let dispatched = r.req.connection._bytesDispatched;
101+
let percent = dispatched * 100.0 / size;
102+
obj.bar1.update(percent, {
103+
speed: ((dispatched / (Date.now() - obj.startTime)) / 125).toFixed(2) //kbits per sec
104+
});
105+
} else {
106+
logger.warn('Connection is undefined/null for zip upload request. Unable to determine progress.');
107+
}
104108
}, 150);
105109

106110
});

0 commit comments

Comments
 (0)