Skip to content

Conversation

@jacob-rogers
Copy link

Found some cases when total attribute may not be defined as Number/String/undefined, but could be a NaN format implicitly or not.

For example, my app using node-progress lib and has no request validation for incoming data Content-Length attribute.
But it was actually passed into const total = parseInt(contentLength, 10) as undefined.
And total has taken NaN.

Eventually, it throws the errors like described in #166:

complete = Array(Math.max(0, completeLength + 1)).join(this.chars.complete);
             ^

RangeError: Invalid array length
    at ProgressBar.render (.../node_modules/progress/lib/node-progress.js:155:14)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

where completeLength takes NaN from total.

Perhaps it could be more convenient to track if we missed a real total value transmitted if it throws when constructor of ProgressBar called.

I will be grateful if someone responds to this. Thanks.

@alwxkxk alwxkxk mentioned this pull request Apr 10, 2019
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.

1 participant