Worker thread terminated even if handled in on error()


#1

Hi,

I am trying to use worker thread to handle a parallel background operation. The worker is created fine and the two threads are able to post messages between each other. However, if an exception occurs in the worker thread, the worker is getting terminated even if I handle the exception in global.onerror

Code snippet below where I am attempting to simulate the condition by throwing an exception in the onmessage. Am I doing something wrong ? I expect the thread not to be terminated.

UI thread:

workerThread = new Worker(’./worker’);
workerThread.postMessage({ “payload”: payload });

Worker thread:
global.onmessage = function(msg) {

throw “some error message”; // simulation of an exception
};
global.onerror = function(e) { // expect the thread not to be terminated
console.log(e);
return true; // do not escalate further
};


$ tns --version
4.0.2


Thank you.