Error Handling Confusion..

113 views
Skip to first unread message

Mike Raistrick

unread,
Oct 7, 2014, 2:07:54 AM10/7/14
to autob...@googlegroups.com
Hi,
If I run this javascript file with node:
testy = function () {
  console.log('Connection opened');
  var d = {};
  var e = d.bill;
  var f = d.bill.jill;
  console.log('Bye now..')
};

testy();

I get a TypeError which I would expect:

$ node autobahn_test2.js
Connection opened

/home/asbo/autobahn_test2.js:5
  var f = d.bill.jill;
                ^
TypeError: Cannot read property 'jill' of undefined
    at testy (/home/asbo/autobahn_test2.js:5:17)
    at Object.<anonymous> (/home/asbo/autobahn_test2.js:9:1)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

But using autobahn:
var autobahn = require('autobahn');

var connection = new autobahn.Connection({
  url: 'ws://127.0.0.1:8080/ws',
  realm: 'realm1'
});

connection.onopen = function (session) {
  console.log('Connection opened');
  var d = {};
  var e = d.bill;
  var f = d.bill.jill;
  console.log('Bye now..')
};

connection.open();

There is no error, and the process doesn't exit:
$ node autobahn_test.js
Connection opened

I would expect this to exit in the same way. Since the 'Bye now' statement isn't printed, clearly the execution is being stopped by the error, just that the error isn't being shown.

Is this expectation wrong, or am I doing something wrong, or something else?

Any help appreciated.

Cheers

Mike



motosota

unread,
Feb 21, 2015, 5:20:35 AM2/21/15
to autob...@googlegroups.com, michael....@googlemail.com
In case this helps anyone else:

Setting gobal variable AUTOBAHN_DEBUG = true seeems to be the answer - thanks to the hint here https://github.com/tavendo/AutobahnJS/issues/117

The Autobahn webpage only shows this for browswer side: http://autobahn.ws/js/reference.html?highlight=debug#debug-mode

So keys seem to be (a) Global variable and (b) Before autobahn code is included.

Repeating my original example but with

AUTOBAHN_DEBUG = true;

I now see:

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() [TypeError: Cannot read property 'jill' of undefined]

Which is exactly what I wanted

Cheers

Mike

Alexander Gödde

unread,
Feb 21, 2015, 5:53:28 AM2/21/15
to autob...@googlegroups.com, michael....@googlemail.com
Hi Mike!

I've updated the Autobahn|JS documentation to make it clear that debug mode works both in the browser and in Node.js.


Regards,

Alex

Mike Raistrick

unread,
Feb 21, 2015, 6:09:10 AM2/21/15
to autob...@googlegroups.com
Thanks Alex,

would it be possible to note somewhere (debug section or an error handling section)  that debug mode is needed to see runtime or user thrown exceptions within .onopen and .onclose functions?

That knowledge was the main thing I was missing - (and I think is the point in https://github.com/tavendo/AutobahnJS/issues/117).

Thanks again!

Mike

--
You received this message because you are subscribed to the Google Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autobahnws+...@googlegroups.com.
To post to this group, send email to autob...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autobahnws/13459280-1a80-4f3d-8b36-2535fc612d24%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Andrew Eddie

unread,
Jul 9, 2015, 10:21:00 PM7/9/15
to autob...@googlegroups.com, michael....@googlemail.com
I've tried the global AUTOBAHN_DEBUG but it does not seem to be honoured in the callback for a registered procedure. Consider this example:

  session.register('com.example.error', function (args, kwargs, details) {
    require('./i-got-the-path-wrong');
  });

and this reported back:

     Error: done() invoked with non-Error: {"error":"wamp.error.runtime_error","args":["MODULE_NOT_FOUND"],"kwargs":{}}

However, nothing showed in the Crossbar console.

Is it possible for Authobahn(JS) to include a stack trace so it's easier to pinpoint the error?

Thanks in advance.

Regards,
Andrew Eddie


Alexander Gödde

unread,
Jul 11, 2015, 8:26:38 AM7/11/15
to autob...@googlegroups.com, mamb...@gmail.com, michael....@googlemail.com
Hi Andrew!

Making debugging easier is something we're working on (there have been big improvements to logging recently) - and input here is always welcome.

Could you please file an issue in the revelant repository/ies (https://github.com/crossbariohttps://github.com/tavendo/AutobahnJS) stating your use case and what log output you'd like?
I can't promise anything (especially not a timeline), but we'll take your input under consideration.

Regards,

Alex
Reply all
Reply to author
Forward
0 new messages