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

Bar not appearing #195

Open
cobbdb opened this issue Jul 15, 2020 · 1 comment
Open

Bar not appearing #195

cobbdb opened this issue Jul 15, 2020 · 1 comment

Comments

@cobbdb
Copy link

cobbdb commented Jul 15, 2020

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);
}
@henridev
Copy link

facing exactly the same issue any updates on this?

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

No branches or pull requests

2 participants