-
Notifications
You must be signed in to change notification settings - Fork 84
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
[Bug] Console log fills up with empty lines if Multi-bar has more than 15 objects #59
Comments
HI @Japaanis , within the development environment the following snippet is running without any errors. please post a minimal example howto reproduce the error const multibar = new _progress.MultiBar({
clearOnComplete: false,
hideCursor: true,
format: ' processing.. {bar} | {percentage}% of {total}',
stopOnComplete: true
}, _progress.Presets.rect);
console.log("adding bars..");
const bars = [];
for (let i=0; i<30; i++){
bars.push(multibar.create(Math.floor(Math.random()*200), Math.floor(Math.random()*20)));
}
const timer = setInterval(function(){
// increment bars
bars.map(bar => bar.increment());
}, 10);
multibar.on('stop', () => {
console.log("FINISHED");
clearInterval(timer);
});
|
currently i'm unable to reproduce this behaviour - can you please provide a minimal example ? |
Hi @AndiDittrich I have noticed that it happens easier the smaller your terminal window is, if my terminal is able to show everything, then it does not happen, but as soon as its sized a bit smaller than the content in height, it freaks out. Here is some more info: Is there more I can do to help, let me know. |
thanks for the window size hint. generally the window should be bigger than the bar....otherwise it can cause an undefined behaviour. the options the issue is caused be the relative cursor movement within the window - i'm not sure if it is possible to fix this without a virtual framebuffer - but due to possible performance impacts i would avoid to implement it |
I also see the same issue (using Windows 10 Command Prompt) when the multiline output grows taller than the screen height, which @AndiDittrich already addressed. Here's a workaround that worked for my situation. I am running 100's of child processes 25 at a time, so I have a 'total' bar followed by 25 'child' bars, removing completed bars and adding child bars as children complete. Call This is cleaner for me. However, I imagine one could use the |
Also running into this when creating dozens or hundreds of bars and I didn't want to manage which bars to show manually. I made a hacky fix by kicking out old completed items by extending the class. This could potentially be incorporated as a bug fix with an option for the max bars to render simultaneously with undefined/0 meaning don't perform cleanup. My use case generally only has 8 active jobs at a time so I picked 20 arbitrarily since it usually fits and I want to see the recently completed jobs. I decided to move failed reports into a file to keep the visibility lost by dropping inactive bars like this. class FixedMultiBar extends MultiBar {
create(total: number, startValue: number, payload?: any): SingleBar {
this.cleanup()
return super.create(total, startValue, payload)
}
private cleanup() {
// @ts-ignore - internal API. Keep in sync with code when updating
const bars = this.bars
if (bars.length > 20) {
// clear the initial completed items up to current total - 20
for (let i = 0, to = bars.length - 20; i < to; i++) {
const inst = bars[i]
// @ts-ignore - internal API. Keep in sync with code when updating
if (!inst.isActive) {
this.remove(inst!)
} else {
break
}
}
}
}
} |
Same issue here |
This worked good enough for me. only issue to point out is that the constructor lacks the option field passed to the super class. |
I create a multi-bar and create continuously create new bars to it, during which some of the bars have already finished. After I have added approximately 15 bars, when a new bar is added, it appears that the previous bars are replaced by empty lines and then the whole console log is filled with empty lines and now and then a bar pops up.
The text was updated successfully, but these errors were encountered: