【问题标题】:javascript errors do not show in the console when using autobahnjs使用 autobahnjs 时,控制台中不显示 javascript 错误
【发布时间】:2014-10-09 19:13:18
【问题描述】:

如果我在connection.onopen函数内部产生错误,使用node运行时控制台不会报错:

connection.onopen = function (session) {
  console.log('Connection opened');
  throw('wobble');
  console.log('Bye now..');
};

控制台显示:

node autobahn_test.js
Connection opened

因此,代码中的任何错误都很难发现。 我搜索了邮件列表,阅读了 API 并尝试阅读有关承诺吞咽错误的信息——因为我感觉这就是这里发生的事情。但到目前为止还没有运气。

谁能告诉我我做错了什么?

谢谢

迈克

【问题讨论】:

  • 我在这里找到了对这个问题的参考:groups.google.com/d/topic/autobahnws/qzNEjfVo258/discussion 我认为你在正确的轨道上。通读该线程,您将看到对 whenjs 的引用和默默吞咽异常,以及一个称为拒绝处理程序的东西。
  • 我将整个代码放在了 connection.onopen 和 connection.onclose 中,作为解决方法。我仍然想知道正确的解决方案。

标签: javascript autobahn


【解决方案1】:

设置 gobal 变量 AUTOBAHN_DEBUG = true 似乎是答案 - 感谢这里的提示 https://github.com/tavendo/AutobahnJS/issues/117

Autobahn 网页仅在浏览器端显示此内容: http://autobahn.ws/js/reference.html?highlight=debug#debug-mode

所以键似乎是 (a) 全局变量和 (b) 在包含高速公路代码之前。

重复我原来的例子,但使用

AUTOBAHN_DEBUG = true;

我现在明白了:

AutobahnJS debug enabled
trying to create WAMP transport of type: websocket
using WAMP transport type: websocket
Connection opened
Exception raised from app code while firing Connection.onopen() wobble

这正是我想要的

希望这可能对其他人有所帮助。

迈克

【讨论】:

    猜你喜欢
    • 2017-01-19
    • 2021-02-13
    • 1970-01-01
    • 2013-10-03
    • 2016-04-08
    • 2020-05-14
    • 2019-12-14
    • 1970-01-01
    • 2018-05-28
    相关资源
    最近更新 更多