A simple solution for accessing messages / data from a worker for debugging purposes is to use postMessage() from your workflow to pass the required debugging information.
These messages can then be "caught" in the handler of the parent onmessage process, which can, for example, log messages / data transferred from the worker to the console. This has the advantage of being a non-blocking approach and allowing workflows to work like real threads and debug in a normal browser environment. While this solution does not include checking the workflow level of the workflow at the breakpoint level, in many situations it provides the ability to display as much or as little data from the workflow as possible to aid in debugging.
A simple implementation might look like this (corresponding excerpts):
// Somewhere in the working onmessage working onmessage (use as often as possible):
postMessage({debug:{message:"This is a debug message"}});
// In the parent onmessage handler:
myWorker.onmessage = function(event) { if(event.data && event.data.debug) { // handle debug message processing here... if(event.data.debug.message) { console.log("message from worker: %o", event.data.debug.message); } } else { // handle regular message processing here... } };
bluebinary Sep 16 '16 at 8:46 2016-09-16 08:46
source share