Skip to content

Add null check while updating progress bar #455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions bin/helpers/zipUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,20 @@ const uploadSuits = (bsConfig, filePath, opts, obj) => {
});

obj.zipInterval = setInterval(function () {
let dispatched = r.req.connection._bytesDispatched;
let percent = dispatched * 100.0 / size;
obj.bar1.update(percent, {
speed: ((dispatched / (Date.now() - obj.startTime)) / 125).toFixed(2) //kbits per sec
});
try {
if (r && r.req && r.req.connection) {
let dispatched = r.req.connection._bytesDispatched;
let percent = dispatched * 100.0 / size;
obj.bar1.update(percent, {
speed: ((dispatched / (Date.now() - obj.startTime)) / 125).toFixed(2) //kbits per sec
});
} else {
logger.warn('Connection is undefined/null for zip upload request. Unable to determine progress.');
}
} catch (error) {
logger.warn('Unable to determine progress.');
logger.error(error);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we push the error at line 111 and 107?

}
}, 150);

});
Expand Down