progress

progress([n])

Emits a progress event. Every work function must invoke this function. If a progress event is not emitted within 30 seconds, the scheduler will throw an ENOPROGRESS error.

Arguments:
  • n (string|number|undefined) – An estimate between 0 and 1 (inclusive) of the ratio of work completed to the total amount of work that needs to be done for one slice. This value must be between 6 significant digits and must always be increasing as more work is continuously being done.

Example:

This example counts from 1 to 1,000,000 where the progress bar is incremented up by one millionth each time.

const job = compute.for(1, 20, function workFn() {
  for (let i = 0; i < 1000000; i += 1) {
    progress(i / 1000000);
  }
});

Tutorials: