codecamp

WebSockect连接错误

若WebSocket后端出现错误时,WebSockect连接错误则有可能出错:

var ws = new WebSocket("wss://ap.fundebug.com/api/events/count");

Fundebug插件捕获的这个错误之后,开发者将受到报警,然后可以在我们的控制台查看错误详情:


Fundebug插件捕获的错误数据如下:

{
    "notifierVersion": "1.5.1",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36",
    "locale": "zh-CN",
    "url": "http://localhost:3001",
    "title": "TEST",
    "releaseStage": null,
    "time": 1546522748886,
    "type": "websocketError",
    "target": {
        "type": "onerror",
        "url": "wss://ap.fundebug.com/api/events/count",
        "timeStamp": 835.6999999959953
    }
}

silentWebsocket

如果你不需要监控WebSocket连接错误,则可以将silentWebsocket属性设为true。

if ("fundebug" in window) {
   fundebug.silentWebsocket = true;
}


unhandledrejection
apikey
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

接入插件

NPM

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }