Frequently asked questions
console.log in the worker not working
Every JavaScript programming environment features an implementation of console.log, and DCP is no different. When your work function invokes console.log(), DCP stringifies the log message and sends it over the network to the scheduler, which relays it to your DCP client app. To capture these events in your client program, do the following with your Job():
job.on('console', (message) => console.log(message));
The Job isn’t receiving any errors
If your work function throws an uncaught exception, DCP relays its details back to your client app as an event.
Note
Your job is cancelled by the scheduler if it does this too many times.
To capture these events and get details on the exception in your client program, do the following with your Job():
job.on('error', (message) => console.log(message));
Receiving an ENOPROGRESS error
This happens when your work function hasn’t called the progress() function within 30 seconds.
Caution
Remember that some worker computers can be much slower than yours!
Note
Every work function must invoke progress() at least once.
The ideal way to invoke progress() is to place it somewhere in your inner loops where you can reasonably expect the work function to call it every 3 or 4 seconds. If your program invokes it too frequently, DCP throttles these calls to help your workload run faster.
Warning
Don’t be tempted to use setInterval() or setTimeout() to invoke progress() - it will not behave the way you think it will unless you are very familiar with the inner workings of the JavaScript event loop.