Skip to content
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

Add null check while updating progress bar #455

Merged

Conversation

prajwaldhawarikar-bs
Copy link
Contributor

Comment on lines 99 to 107
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.');
}
Copy link
Member

Choose a reason for hiding this comment

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

Let's include this within a try catch block to catch errors that might come from other lines of code.

}
} 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?

@agrawalsaurabhs agrawalsaurabhs merged commit 60de54d into master Mar 1, 2023
@agrawalsaurabhs agrawalsaurabhs deleted the AFD-1532-null-check-while-updating-progress-bar branch March 1, 2023 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants