如何从node-webworker-threads中获得控制台的错误?

我正在开发一个node.js应用程序。 我正在使用webworker-threads包去掉一些CPU阻塞任务。 但是,我的线程代码中未被捕获的错误不会被发送到控制台。 相反,线程只是失败的默默。 最简单的例子说明了这一点:

var Threads = require('webworker-threads'); this.testThread = new Threads.Worker( function() { console.log("This is the test thread. The next line should throw an error."); undefinedFunction(); } ); 

由于我的实际应用程序正在调用一个单独的js文件作为线程,我也没有看到任何语法错误报告。 是否有一些无证的错误事件我应该赶上? 我的环境可能有问题吗?

尝试绑定到worker的onerror事件:

 var webpackWorker = new Worker(function() { this.onmessage = function(event) { throw ('test'); }; }); webpackWorker.onerror = function (event) { console.log(event); } webpackWorker.postMessage("dummy");