如何调试共享的Webworkers? [英] How to debug shared webworkers?

查看:461
本文介绍了如何调试共享的Webworkers?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用共享的Webworkers,但我没有从工作人员那里得到错误。工作者错误处理程序不返回任何错误!我该如何调试共享的Webworkers。

I am using shared webworkers, I am not getting the errors from the worker. The worker error handler not returning any errors!. How can I Debug shared webworkers.

var worker = new SharedWorker('Vult_worker.js');
    worker.port.start();
    worker.port.onerror = function(e) {
        consloe.log('ERROR: Line ', e.lineno, ' in ', e.filename, ': ', e.message);
    }

    worker.port.onmessage = function(e) {
        console.log(e.data);
    };
worker.port.postmessage();

工人代码:

onconnect = function(e) {
    var self = e.ports[0];
self.onmessage=function(){
self.postmessage(1/x);
}


推荐答案

导航到 chrome:// inspect /#workers 并找到共享的工作程序,然后单击检查。然后,您可以为SharedWorker调出控制台。

Navigate to chrome://inspect/#workers and find the shared worker and click on "inspect". Then you can pull up the console for the SharedWorker.

这篇关于如何调试共享的Webworkers?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆