node-progress icon indicating copy to clipboard operation
node-progress copied to clipboard

Bar not appearing

Open cobbdb opened this issue 3 years ago • 1 comments

I'm trying to use this library inside of threads, but for some reason I don't see any bars being drawn. It seems to work fine without threads though so I'm hoping someone knows what's going on here?

const ProgressBar = require('progress');
const {
  Worker,
  isMainThread,
  parentPort,
  workerData,
} = require('worker_threads');
const files = {
  'eta.js': 187,
  'generic-bar.js': 589,
  'multi-bar.js': 5342,
  'options.js': 42,
  'single-bar.js': 2123,
  'terminal.js': 4123,
};

if (isMainThread) {
  const entries = Object.entries(files);
  for (const file of entries) {
    const worker = new Worker(__filename, { workerData: file });
    worker.on('message', (data) => {
      console.log('... OK', data);
    });
    worker.on('error', (err) => {
      console.log('[ERR]', err);
    });
    worker.on('exit', (code) => {
      if (code !== 0) {
        console.log(`Worker stopped with exit code ${code}`);
      }
    });
  }
} else {
  console.log('... making new bar', workerData);
  const bar = new ProgressBar(':bar', {
    total: workerData[1],
  });

  const timer = setInterval(() => {
    bar.tick();
    if (bar.complete) {
      clearInterval(timer);
    }
  }, 3);
}

cobbdb avatar Jul 15 '20 08:07 cobbdb

facing exactly the same issue any updates on this?

henridev avatar Mar 26 '21 05:03 henridev